diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index ed5c065631e..1d707f54345 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -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 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()); diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index bfb2248f961..d45cf1dade2 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -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);