From 91fb5de6452a8d3499dd397a5e52d9f252c07ad9 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 20 Mar 2025 15:54:59 +0800 Subject: [PATCH] crimson/os/seastore: misc renames Signed-off-by: Yingxin Cheng --- .../os/seastore/btree/btree_range_pin.h | 2 +- src/crimson/os/seastore/cache.cc | 6 ++--- src/crimson/os/seastore/cache.h | 4 ++-- src/crimson/os/seastore/cached_extent.cc | 4 ++-- src/crimson/os/seastore/cached_extent.h | 22 +++++++++++-------- src/crimson/os/seastore/linked_tree_node.h | 4 ++-- src/crimson/os/seastore/transaction.h | 18 +++++++-------- 7 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/crimson/os/seastore/btree/btree_range_pin.h b/src/crimson/os/seastore/btree/btree_range_pin.h index bfd350a8bed..b8fb5085aaf 100644 --- a/src/crimson/os/seastore/btree/btree_range_pin.h +++ b/src/crimson/os/seastore/btree/btree_range_pin.h @@ -182,7 +182,7 @@ public: assert(extent.is_pending_in_trans(t.get_trans_id())); return false; } - auto &pendings = extent.mutation_pendings; + auto &pendings = extent.mutation_pending_extents; auto trans_id = t.get_trans_id(); bool unviewable = (pendings.find(trans_id, trans_spec_view_t::cmp_t()) != pendings.end()); diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 2a2488d64cd..4dd49caf8ca 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -919,14 +919,14 @@ void Cache::invalidate_extent( CachedExtent& extent) { if (!extent.may_conflict()) { - assert(extent.transactions.empty()); + assert(extent.read_transactions.empty()); extent.set_invalid(t); return; } LOG_PREFIX(Cache::invalidate_extent); bool do_conflict_log = true; - for (auto &&i: extent.transactions) { + for (auto &&i: extent.read_transactions) { if (!i.t->conflicted) { if (do_conflict_log) { SUBDEBUGT(seastore_t, "conflict begin -- {}", t, extent); @@ -1181,7 +1181,7 @@ CachedExtentRef Cache::duplicate_for_write( ret->prior_instance = i; // duplicate_for_write won't occur after ool write finished assert(!i->prior_poffset); - auto [iter, inserted] = i->mutation_pendings.insert(*ret); + auto [iter, inserted] = i->mutation_pending_extents.insert(*ret); ceph_assert(inserted); t.add_mutated_extent(ret); if (is_root_type(ret->get_type())) { diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index a916e13e311..8dfaa04cbcd 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -688,8 +688,8 @@ private: on_cache(*ret); // replace placeholder in transactions - while (!cached->transactions.empty()) { - auto t = cached->transactions.begin()->t; + while (!cached->read_transactions.empty()) { + auto t = cached->read_transactions.begin()->t; t->replace_placeholder(*cached, *ret); } diff --git a/src/crimson/os/seastore/cached_extent.cc b/src/crimson/os/seastore/cached_extent.cc index 8a00a6d4d83..6bceb999c37 100644 --- a/src/crimson/os/seastore/cached_extent.cc +++ b/src/crimson/os/seastore/cached_extent.cc @@ -81,8 +81,8 @@ CachedExtent* CachedExtent::get_transactional_view(Transaction &t) { } CachedExtent* CachedExtent::get_transactional_view(transaction_id_t tid) { - auto it = mutation_pendings.find(tid, trans_spec_view_t::cmp_t()); - if (it != mutation_pendings.end()) { + auto it = mutation_pending_extents.find(tid, trans_spec_view_t::cmp_t()); + if (it != mutation_pending_extents.end()) { return (CachedExtent*)&(*it); } else { return this; diff --git a/src/crimson/os/seastore/cached_extent.h b/src/crimson/os/seastore/cached_extent.h index 1bed954713b..81f79044356 100644 --- a/src/crimson/os/seastore/cached_extent.h +++ b/src/crimson/os/seastore/cached_extent.h @@ -74,7 +74,7 @@ class read_set_item_t { &read_set_item_t::trans_hook>; public: - struct cmp_t { + struct extent_cmp_t { using is_transparent = paddr_t; bool operator()(const read_set_item_t &lhs, const read_set_item_t &rhs) const; bool operator()(const paddr_t &lhs, const read_set_item_t &rhs) const; @@ -113,10 +113,14 @@ public: read_set_item_t(read_set_item_t &&) = default; ~read_set_item_t() = default; }; + template -using read_set_t = std::set< +using read_extent_set_t = std::set< read_set_item_t, - typename read_set_item_t::cmp_t>; + typename read_set_item_t::extent_cmp_t>; + +template +using read_trans_set_t = typename read_set_item_t::trans_set_t; struct trans_spec_view_t { // if the extent is pending, contains the id of the owning transaction; @@ -874,7 +878,7 @@ private: CachedExtent* get_transactional_view(Transaction &t); CachedExtent* get_transactional_view(transaction_id_t tid); - read_set_item_t::trans_set_t transactions; + read_trans_set_t read_transactions; placement_hint_t user_hint = PLACEMENT_HINT_NULL; @@ -883,7 +887,7 @@ private: rewrite_gen_t rewrite_generation = NULL_GENERATION; protected: - trans_view_set_t mutation_pendings; + trans_view_set_t mutation_pending_extents; trans_view_set_t retired_transactions; CachedExtent(CachedExtent &&other) = delete; @@ -1169,7 +1173,7 @@ template class addr_extent_set_base_t : public std::set {}; -using pextent_set_t = addr_extent_set_base_t< +using retired_extent_set_t = addr_extent_set_base_t< paddr_t, trans_retired_extent_link_t, ref_paddr_cmp @@ -1468,17 +1472,17 @@ read_set_item_t::read_set_item_t(T *t, CachedExtentRef ref) {} template -inline bool read_set_item_t::cmp_t::operator()( +inline bool read_set_item_t::extent_cmp_t::operator()( const read_set_item_t &lhs, const read_set_item_t &rhs) const { return lhs.ref->poffset < rhs.ref->poffset; } template -inline bool read_set_item_t::cmp_t::operator()( +inline bool read_set_item_t::extent_cmp_t::operator()( const paddr_t &lhs, const read_set_item_t &rhs) const { return lhs < rhs.ref->poffset; } template -inline bool read_set_item_t::cmp_t::operator()( +inline bool read_set_item_t::extent_cmp_t::operator()( const read_set_item_t &lhs, const paddr_t &rhs) const { return lhs.ref->poffset < rhs; } diff --git a/src/crimson/os/seastore/linked_tree_node.h b/src/crimson/os/seastore/linked_tree_node.h index 76be226ebb7..9ed0f67fb77 100644 --- a/src/crimson/os/seastore/linked_tree_node.h +++ b/src/crimson/os/seastore/linked_tree_node.h @@ -302,9 +302,9 @@ public: TCachedExtentRef find_pending_version(Transaction &t, node_key_t key) { auto &me = down_cast(); assert(me.is_stable()); - auto mut_iter = me.mutation_pendings.find( + auto mut_iter = me.mutation_pending_extents.find( t.get_trans_id(), trans_spec_view_t::cmp_t()); - if (mut_iter != me.mutation_pendings.end()) { + if (mut_iter != me.mutation_pending_extents.end()) { assert(copy_dests_by_trans.find(t.get_trans_id()) == copy_dests_by_trans.end()); return static_cast(&(*mut_iter)); diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index cd8c333c69f..a3dfa7261a0 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -171,15 +171,15 @@ public: assert(ref->is_valid()); - auto it = ref->transactions.lower_bound( + auto it = ref->read_transactions.lower_bound( this, read_set_item_t::trans_cmp_t()); - if (it != ref->transactions.end() && it->t == this) { + if (it != ref->read_transactions.end() && it->t == this) { return false; } auto [iter, inserted] = read_set.emplace(this, ref); ceph_assert(inserted); - ref->transactions.insert_before( + ref->read_transactions.insert_before( it, const_cast&>(*iter)); return true; } @@ -191,13 +191,13 @@ public: assert(ref->is_valid()); - auto it = ref->transactions.lower_bound( + auto it = ref->read_transactions.lower_bound( this, read_set_item_t::trans_cmp_t()); - assert(it == ref->transactions.end() || it->t != this); + assert(it == ref->read_transactions.end() || it->t != this); auto [iter, inserted] = read_set.emplace(this, ref); ceph_assert(inserted); - ref->transactions.insert_before( + ref->read_transactions.insert_before( it, const_cast&>(*iter)); } @@ -306,7 +306,7 @@ public: assert(where->ref.get() == &placeholder); where = read_set.erase(where); auto it = read_set.emplace_hint(where, this, &extent); - extent.transactions.insert(const_cast&>(*it)); + extent.read_transactions.insert(const_cast&>(*it)); } { auto where = retired_set.find(&placeholder); @@ -610,7 +610,7 @@ private: * Submitting a transaction mutating any contained extent/addr will * invalidate *this. */ - read_set_t read_set; ///< set of extents read by paddr + read_extent_set_t read_set; ///< set of extents read by paddr uint64_t fresh_backref_extents = 0; // counter of new backref extents @@ -663,7 +663,7 @@ private: * * Set of extents retired by *this. */ - pextent_set_t retired_set; + retired_extent_set_t retired_set; /// stats to collect when commit or invalidate tree_stats_t onode_tree_stats; -- 2.39.5