From: Yingxin Cheng Date: Wed, 2 Apr 2025 02:31:58 +0000 (+0800) Subject: crimson/os/seastore: factor out a do_add_to_read_set() X-Git-Tag: v20.3.0~129^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3389fdde448061b24689ef998eb2bae81758343;p=ceph.git crimson/os/seastore: factor out a do_add_to_read_set() Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index 783336ff92dd..514a6fc58fba 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -98,17 +98,6 @@ struct rbm_pending_ool_t { * - seastore_cache logs */ class Transaction { -private: - auto lookup_read_set(CachedExtentRef ref) const { - assert(ref->is_valid()); - assert(!is_weak()); - auto it = ref->read_transactions.lower_bound( - this, read_set_item_t::trans_cmp_t()); - bool exists = - (it != ref->read_transactions.end() && it->t == this); - return std::make_pair(exists, it); - } - public: using Ref = std::unique_ptr; using on_destruct_func_t = std::function; @@ -130,7 +119,8 @@ public: } void add_absent_to_retired_set(CachedExtentRef ref) { - add_to_read_set(ref); + bool added = do_add_to_read_set(ref); + ceph_assert(added); add_present_to_retired_set(ref); } @@ -169,18 +159,7 @@ public: if (is_weak()) { return false; } - - assert(ref->is_stable()); - auto [exists, it] = lookup_read_set(ref); - if (exists) { - return false; - } - - auto [iter, inserted] = read_set.emplace(this, ref); - ceph_assert(inserted); - ref->read_transactions.insert_before( - it, const_cast&>(*iter)); - return true; + return do_add_to_read_set(ref); } void add_to_read_set(CachedExtentRef ref) { @@ -188,14 +167,8 @@ public: return; } - assert(ref->is_stable()); - auto [exists, it] = lookup_read_set(ref); - assert(!exists); - - auto [iter, inserted] = read_set.emplace(this, ref); - ceph_assert(inserted); - ref->read_transactions.insert_before( - it, const_cast&>(*iter)); + bool added = do_add_to_read_set(ref); + ceph_assert(added); } void add_fresh_extent( @@ -607,6 +580,31 @@ private: } } + auto lookup_read_set(CachedExtentRef ref) const { + assert(ref->is_valid()); + assert(!is_weak()); + auto it = ref->read_transactions.lower_bound( + this, read_set_item_t::trans_cmp_t()); + bool exists = + (it != ref->read_transactions.end() && it->t == this); + return std::make_pair(exists, it); + } + + bool do_add_to_read_set(CachedExtentRef ref) { + assert(!is_weak()); + assert(ref->is_stable()); + auto [exists, it] = lookup_read_set(ref); + if (exists) { + return false; + } + + auto [iter, inserted] = read_set.emplace(this, ref); + ceph_assert(inserted); + ref->read_transactions.insert_before( + it, const_cast&>(*iter)); + return true; + } + void set_backref_entries(backref_entry_refs_t&& entries) { assert(backref_entries.empty()); backref_entries = std::move(entries);