Skip to content

Commit

Permalink
updated variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhaskar Bora committed Feb 4, 2025
1 parent 56187de commit 6d70676
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
23 changes: 11 additions & 12 deletions src/llfs/page_recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ StatusOr<SlotRange> refresh_recycler_info_slot(TypedSlotWriter<PageRecycleEvent>

return std::unique_ptr<PageRecycler>{
new PageRecycler(scheduler, std::string{name}, page_deleter, std::move(*recovered_log),
std::move(latest_batch), std::move(state), visitor.largest_unique_offset(),
std::move(latest_batch), std::move(state), visitor.volume_trim_offset(),
visitor.page_index() + 1)};
}

Expand All @@ -203,7 +203,7 @@ PageRecycler::PageRecycler(batt::TaskScheduler& scheduler, const std::string& na
, recycle_task_{}
, metrics_{}
, prepared_batch_{std::move(recovered_batch)}
, largest_offset_as_unique_identifier_{largest_offset_as_unique_identifier_init}
, volume_trim_slot_{largest_offset_as_unique_identifier_init}
, largest_page_index_{page_index_init}
{
const PageRecyclerOptions& options = this->state_.no_lock().options;
Expand Down Expand Up @@ -334,16 +334,16 @@ bool PageRecycler::is_page_recycling_allowed(const Slice<const PageId>& page_ids
{
// If we got higher offset allow recycle.
//
if (this->largest_offset_as_unique_identifier_ < offset_as_unique_identifier) {
if (this->volume_trim_slot_ < offset_as_unique_identifier) {
// Update the largest unique identifier and index.
//
this->largest_offset_as_unique_identifier_ = offset_as_unique_identifier;
this->volume_trim_slot_ = offset_as_unique_identifier;
this->largest_page_index_ = 0;
return true;
}
// If we got same offset but not all pages were processed last time then allow recycle.
//
else if (this->largest_offset_as_unique_identifier_ == offset_as_unique_identifier &&
else if (this->volume_trim_slot_ == offset_as_unique_identifier &&
this->largest_page_index_ < page_ids.size()) {
return true;
}
Expand Down Expand Up @@ -411,9 +411,9 @@ StatusOr<slot_offset_type> PageRecycler::recycle_pages_depth_0(
{
auto locked_state = this->state_.lock();
// Writing to recycler log.
StatusOr<slot_offset_type> append_slot = this->insert_to_log(
*local_grant, page_id, depth, this->largest_offset_as_unique_identifier_,
this->largest_page_index_, locked_state);
StatusOr<slot_offset_type> append_slot =
this->insert_to_log(*local_grant, page_id, depth, this->volume_trim_slot_,
this->largest_page_index_, locked_state);
BATT_REQUIRE_OK(append_slot);

++this->largest_page_index_;
Expand All @@ -439,9 +439,8 @@ StatusOr<slot_offset_type> PageRecycler::recycle_pages_depth_n(const Slice<const
auto locked_state = this->state_.lock();
for (PageId page_id : page_ids) {
// Writing to recycler log.
StatusOr<slot_offset_type> append_slot =
this->insert_to_log(*grant, page_id, depth, this->largest_offset_as_unique_identifier_,
this->largest_page_index_, locked_state);
StatusOr<slot_offset_type> append_slot = this->insert_to_log(
*grant, page_id, depth, this->volume_trim_slot_, this->largest_page_index_, locked_state);
BATT_REQUIRE_OK(append_slot);

this->last_page_recycle_offset_ = *append_slot;
Expand All @@ -465,7 +464,7 @@ StatusOr<slot_offset_type> PageRecycler::recycle_pages(
<< page_ids.size() << "]"
<< ", grant=[" << (grant ? grant->size() : usize{0}) << "], depth=" << depth << ") "
<< this->name_ << BATT_INSPECT(offset_as_unique_identifier)
<< BATT_INSPECT(this->largest_offset_as_unique_identifier_)
<< BATT_INSPECT(this->volume_trim_slot_)
<< BATT_INSPECT(this->last_page_recycle_offset_);

if (page_ids.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/llfs/page_recycler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class PageRecycler

Optional<slot_offset_type> latest_batch_upper_bound_;

slot_offset_type largest_offset_as_unique_identifier_;
slot_offset_type volume_trim_slot_;

u16 largest_page_index_;

Expand Down
15 changes: 7 additions & 8 deletions src/llfs/page_recycler_recovery_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace llfs {
, latest_batch_{}
, recycler_uuid_{boost::uuids::random_generator{}()}
, latest_info_refresh_slot_{}
, largest_offset_as_unique_identifier_{0}
, volume_trim_slot_{0}
, largest_page_index_{0}
{
initialize_status_codes();
Expand Down Expand Up @@ -115,9 +115,9 @@ Optional<SlotRange> PageRecyclerRecoveryVisitor::latest_info_refresh_slot() cons

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
slot_offset_type PageRecyclerRecoveryVisitor::largest_unique_offset() const
slot_offset_type PageRecyclerRecoveryVisitor::volume_trim_offset() const
{
return this->largest_offset_as_unique_identifier_;
return this->volume_trim_slot_;
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
Expand All @@ -133,8 +133,7 @@ Status PageRecyclerRecoveryVisitor::operator()(const SlotParse& slot,
const PageToRecycle& recovered)
{
LLFS_VLOG(1) << "Recovered slot: " << slot.offset << " " << recovered
<< BATT_INSPECT((bool)this->latest_batch_)
<< BATT_INSPECT(this->largest_offset_as_unique_identifier_)
<< BATT_INSPECT((bool)this->latest_batch_) << BATT_INSPECT(this->volume_trim_slot_)
<< BATT_INSPECT(this->largest_page_index_);

// Add the new record, or verify that the existing one and the new one are equivalent.
Expand Down Expand Up @@ -162,10 +161,10 @@ Status PageRecyclerRecoveryVisitor::operator()(const SlotParse& slot,
// Save the largest unique offset identifier. Note that if offsets are same then we need to only
// update the largest page_index.
//
if (this->largest_offset_as_unique_identifier_ < recovered.offset_as_unique_identifier) {
this->largest_offset_as_unique_identifier_ = recovered.offset_as_unique_identifier;
if (this->volume_trim_slot_ < recovered.offset_as_unique_identifier) {
this->volume_trim_slot_ = recovered.offset_as_unique_identifier;
this->largest_page_index_ = recovered.page_index;
} else if (this->largest_offset_as_unique_identifier_ == recovered.offset_as_unique_identifier &&
} else if (this->volume_trim_slot_ == recovered.offset_as_unique_identifier &&
this->largest_page_index_ < recovered.page_index) {
this->largest_page_index_ = recovered.page_index;
}
Expand Down
4 changes: 2 additions & 2 deletions src/llfs/page_recycler_recovery_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PageRecyclerRecoveryVisitor

Optional<SlotRange> latest_info_refresh_slot() const;

slot_offset_type largest_unique_offset() const;
slot_offset_type volume_trim_offset() const;
u16 page_index() const;

//+++++++++++-+-+--+----- --- -- - - - -
Expand Down Expand Up @@ -85,7 +85,7 @@ class PageRecyclerRecoveryVisitor

// This is to track largest unique_offset value during recovery.
//
slot_offset_type largest_offset_as_unique_identifier_;
slot_offset_type volume_trim_slot_;

// This tracks the largest page_index seen so far for a given offset.
//
Expand Down

0 comments on commit 6d70676

Please sign in to comment.