crimson/os/seastore/cache: factor out remove_from_dirty

Signed-off-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2021-04-19 00:36:28 -07:00
parent 9b5d2042ee
commit 851dd14f75
2 changed files with 16 additions and 8 deletions

View File

@ -86,12 +86,8 @@ void Cache::add_to_dirty(CachedExtentRef ref)
dirty.push_back(*ref);
}
void Cache::remove_extent(CachedExtentRef ref)
void Cache::remove_from_dirty(CachedExtentRef ref)
{
logger().debug("remove_extent: {}", *ref);
assert(ref->is_valid());
extents.erase(*ref);
if (ref->is_dirty()) {
ceph_assert(ref->primary_ref_list_hook.is_linked());
dirty.erase(dirty.s_iterator_to(*ref));
@ -101,6 +97,14 @@ void Cache::remove_extent(CachedExtentRef ref)
}
}
void Cache::remove_extent(CachedExtentRef ref)
{
logger().debug("remove_extent: {}", *ref);
assert(ref->is_valid());
remove_from_dirty(ref);
extents.erase(*ref);
}
void Cache::replace_extent(CachedExtentRef next, CachedExtentRef prev)
{
assert(next->get_paddr() == prev->get_paddr());
@ -255,9 +259,7 @@ std::optional<record_t> Cache::try_construct_record(Transaction &t)
// invalidate now invalid blocks
for (auto &i: t.retired_set) {
logger().debug("try_construct_record: retiring {}", *i);
ceph_assert(i->is_valid());
remove_extent(i);
i->state = CachedExtent::extent_state_t::INVALID;
retire_extent(i);
}
record.extents.reserve(t.fresh_block_list.size());

View File

@ -548,9 +548,15 @@ private:
/// Add dirty extent to dirty list
void add_to_dirty(CachedExtentRef ref);
/// Remove from dirty list
void remove_from_dirty(CachedExtentRef ref);
/// Remove extent from extents handling dirty and refcounting
void remove_extent(CachedExtentRef ref);
/// Retire extent, move reference to retired_extent_gate
void retire_extent(CachedExtentRef ref);
/// Replace prev with next
void replace_extent(CachedExtentRef next, CachedExtentRef prev);