Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead Page Reference Count Bug Fix #181

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion script
Submodule script updated 1 files
+1 −1 conan-targets.mk
16 changes: 11 additions & 5 deletions src/llfs/committable_page_cache_job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ Status CommittablePageCacheJob::commit_impl(const JobCommitParams& params, u64 c
const PageCacheJob* job = this->job_.get();
BATT_CHECK_NOT_NULLPTR(job);

LLFS_VLOG(1) << "commit(PageCacheJob): entered";
if (durable_caller_slot) {
LLFS_VLOG(1) << "commit(PageCacheJob): entered" << BATT_INSPECT(prev_caller_slot)
<< BATT_INSPECT(*durable_caller_slot);
} else {
LLFS_VLOG(1) << "commit(PageCacheJob): entered" << BATT_INSPECT(prev_caller_slot);
}

// Make sure the job is pruned!
//
Expand Down Expand Up @@ -426,7 +431,7 @@ auto CommittablePageCacheJob::start_ref_count_updates(const JobCommitParams& par
PageRefCountUpdates& updates, u64 /*callers*/)
-> StatusOr<DeadPages>
{
LLFS_VLOG(1) << "commit(PageCacheJob): updating ref counts";
LLFS_VLOG(1) << "commit(PageCacheJob): updating ref counts" << BATT_INSPECT(params.caller_slot);

DeadPages dead_pages;

Expand Down Expand Up @@ -579,10 +584,11 @@ Status CommittablePageCacheJob::recycle_dead_pages(const JobCommitParams& params

BATT_ASSIGN_OK_RESULT(
slot_offset_type recycler_sync_point,
params.recycler.recycle_pages(as_slice(dead_pages.ids), params.recycle_grant,
params.recycle_depth + 1));
params.recycler.recycle_pages(as_slice(dead_pages.ids), params.caller_slot,
params.recycle_grant, params.recycle_depth + 1));

LLFS_VLOG(1) << "commit(PageCacheJob): waiting for PageRecycler sync point";
LLFS_VLOG(1) << "commit(PageCacheJob): waiting for PageRecycler sync point"
<< BATT_INSPECT(params.caller_slot);

return params.recycler.await_flush(recycler_sync_point);
//
Expand Down
5 changes: 3 additions & 2 deletions src/llfs/page_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ bool PageAllocator::await_ref_count(PageId page_id, i32 ref_count)
if ((counter & 4095) == 0) {
LLFS_LOG_INFO() << BATT_INSPECT(prc) << BATT_INSPECT(page_id) << BATT_INSPECT(ref_count)
<< BATT_INSPECT(counter);
BATT_CHECK_LT(counter, 10 * 1000) << "[PageAllocator::await_ref_count] timed out (10s)"
<< BATT_INSPECT(page_id) << BATT_INSPECT(ref_count);
BATT_CHECK_LT(counter, 10 * 1000)
<< "[PageAllocator::await_ref_count] timed out (10s)" << BATT_INSPECT(page_id)
<< BATT_INSPECT(ref_count) << BATT_INSPECT(prc.ref_count);
}
}
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/llfs/page_allocator_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,14 @@ PageAllocatorState::ProposalStatus PageAllocatorState::propose(PackedPageAllocat
// If this is a valid proposal that will cause state change, go through and change the deltas to
// the new ref count values.
//
LLFS_VLOG(1) << "propose (start): txn-ref-count= " << txn->ref_counts.size();
if (status == ProposalStatus::kValid) {
for (PackedPageRefCount& prc : txn->ref_counts) {
LLFS_VLOG(1) << "reference count: " << prc;
prc.ref_count = this->calculate_new_ref_count(prc);
}
}
LLFS_VLOG(1) << "propose (end): txn-ref-count= " << txn->ref_counts.size();

return status;
}
Expand Down
2 changes: 1 addition & 1 deletion src/llfs/page_allocator_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class PageAllocatorState : public PageAllocatorStateNoLock

// Returns the new ref count that will result from applying the delta to the passed obj.
//
i32 calculate_new_ref_count(const PackedPageRefCount& delta) const;
i32 calculate_new_ref_count(const PackedPageRefCount& deltaa) const;

/** \brief If the given ref count object has a positive ref count but *is* in the free pool, then
* this function removes it; otherwise if the object has a zero ref count but is *not* in the free
Expand Down
Loading