]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/OnodeManager: adapt laddr_hint_t approach
authorZhang Song <zhangsong02@qianxin.com>
Wed, 11 Jun 2025 04:04:03 +0000 (12:04 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Sun, 24 May 2026 04:06:20 +0000 (12:06 +0800)
Signed-off-by: Zhang Song <zhangsong02@qianxin.com>
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/onode_manager/staged-fltree/node.cc
src/crimson/os/seastore/onode_manager/staged-fltree/node.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.cc
src/crimson/os/seastore/onode_manager/staged-fltree/node_impl.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_layout.h
src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc
src/test/crimson/seastore/onode_tree/test_staged_fltree.cc

index ef0d670f37002c2009ab74ce52fd4d19c3985c1c..b83831f5a3fa7a0ad8b982990732cf71cdf630e9 100644 (file)
@@ -477,7 +477,7 @@ Super::URef Node::deref_super()
   return ret;
 }
 
-eagain_ifuture<> Node::upgrade_root(context_t c, laddr_t hint)
+eagain_ifuture<> Node::upgrade_root(context_t c, laddr_hint_t hint)
 {
   LOG_PREFIX(OTree::Node::upgrade_root);
   assert(impl->field_type() == field_type_t::N0);
@@ -1210,7 +1210,7 @@ eagain_ifuture<std::pair<Ref<Node>, Ref<Node>>> InternalNode::get_child_peers(
 }
 
 eagain_ifuture<Ref<InternalNode>> InternalNode::allocate_root(
-    context_t c, laddr_t hint, level_t old_root_level,
+    context_t c, laddr_hint_t hint, level_t old_root_level,
     laddr_t old_root_addr, Super::URef&& super)
 {
   // support tree height up to 256
@@ -1376,7 +1376,9 @@ eagain_ifuture<> InternalNode::test_clone_root(
   assert(impl->is_level_tail());
   assert(impl->field_type() == field_type_t::N0);
   Ref<const Node> this_ref = this;
-  return InternalNode::allocate(c_other, L_ADDR_MIN, field_type_t::N0, true, impl->level()
+  return InternalNode::allocate(
+    c_other, laddr_hint_t::create_global_md_hint(),
+    field_type_t::N0, true, impl->level()
   ).si_then([this, c_other, &tracker_other](auto fresh_other) {
     impl->test_copy_to(fresh_other.mut);
     auto cloned_root = fresh_other.node;
@@ -1487,14 +1489,14 @@ eagain_ifuture<Ref<InternalNode>> InternalNode::insert_or_split(
 
   // proceed to split with insert
   // assume I'm already ref-counted by caller
-  laddr_t left_hint, right_hint;
+  laddr_hint_t left_hint, right_hint;
   {
     key_view_t left_key;
     impl->get_slot(search_position_t::begin(), &left_key, nullptr);
-    left_hint = left_key.get_hint();
+    left_hint = left_key.create_onode_hint();
     key_view_t right_key;
     impl->get_largest_slot(nullptr, &right_key, nullptr);
-    right_hint = right_key.get_hint();
+    right_hint = right_key.create_onode_hint();
   }
   return (is_root() ? upgrade_root(c, left_hint) : eagain_iertr::now()
   ).si_then([this, c, right_hint] {
@@ -1743,7 +1745,7 @@ void InternalNode::validate_child_inconsistent(const Node& child) const
 }
 
 eagain_ifuture<InternalNode::fresh_node_t> InternalNode::allocate(
-    context_t c, laddr_t hint, field_type_t field_type, bool is_level_tail, level_t level)
+    context_t c, laddr_hint_t hint, field_type_t field_type, bool is_level_tail, level_t level)
 {
   return InternalNodeImpl::allocate(c, hint, field_type, is_level_tail, level
   ).si_then([](auto&& fresh_impl) {
@@ -2023,7 +2025,8 @@ eagain_ifuture<> LeafNode::test_clone_root(
   assert(impl->is_level_tail());
   assert(impl->field_type() == field_type_t::N0);
   Ref<const Node> this_ref = this;
-  return LeafNode::allocate(c_other, L_ADDR_MIN, field_type_t::N0, true
+  return LeafNode::allocate(
+    c_other, laddr_hint_t::create_global_md_hint(), field_type_t::N0, true
   ).si_then([this, c_other, &tracker_other](auto fresh_other) {
     impl->test_copy_to(fresh_other.mut);
     auto cloned_root = fresh_other.node;
@@ -2071,14 +2074,14 @@ eagain_ifuture<Ref<tree_cursor_t>> LeafNode::insert_value(
   }
   // split and insert
   Ref<Node> this_ref = this;
-  laddr_t left_hint, right_hint;
+  laddr_hint_t left_hint, right_hint;
   {
     key_view_t left_key;
     impl->get_slot(search_position_t::begin(), &left_key, nullptr);
-    left_hint = left_key.get_hint();
+    left_hint = left_key.create_onode_hint();
     key_view_t right_key;
     impl->get_largest_slot(nullptr, &right_key, nullptr);
-    right_hint = right_key.get_hint();
+    right_hint = right_key.create_onode_hint();
   }
   return (is_root() ? upgrade_root(c, left_hint) : eagain_iertr::now()
   ).si_then([this, c, right_hint] {
@@ -2120,7 +2123,8 @@ eagain_ifuture<Ref<LeafNode>> LeafNode::allocate_root(
     context_t c, RootNodeTracker& root_tracker)
 {
   LOG_PREFIX(OTree::LeafNode::allocate_root);
-  return LeafNode::allocate(c, L_ADDR_MIN, field_type_t::N0, true
+  return LeafNode::allocate(
+    c, laddr_hint_t::create_global_md_hint(), field_type_t::N0, true
   ).si_then([c, &root_tracker, FNAME](auto fresh_node) {
     auto root = fresh_node.node;
     return c.nm.get_super(c.t, root_tracker
@@ -2242,7 +2246,7 @@ void LeafNode::track_erase(
 }
 
 eagain_ifuture<LeafNode::fresh_node_t> LeafNode::allocate(
-    context_t c, laddr_t hint, field_type_t field_type, bool is_level_tail)
+    context_t c, laddr_hint_t hint, field_type_t field_type, bool is_level_tail)
 {
   return LeafNodeImpl::allocate(c, hint, field_type, is_level_tail
   ).si_then([](auto&& fresh_impl) {
index 4311da5fb46a7641999b5fec8a519d21c2e1c747..54c64a4088e90f8a9e9902e66168981de5abc138 100644 (file)
@@ -417,7 +417,7 @@ class Node
     make_root(c, std::move(_super));
   }
   void as_root(Super::URef&& _super);
-  eagain_ifuture<> upgrade_root(context_t, laddr_t);
+  eagain_ifuture<> upgrade_root(context_t, laddr_hint_t);
 
   Super::URef deref_super();
 
@@ -551,7 +551,7 @@ class InternalNode final : public Node {
   void track_make_tail(const search_position_t&);
 
   static eagain_ifuture<Ref<InternalNode>> allocate_root(
-      context_t, laddr_t, level_t, laddr_t, Super::URef&&);
+      context_t, laddr_hint_t, level_t, laddr_t, Super::URef&&);
 
  protected:
   eagain_ifuture<Ref<tree_cursor_t>> lookup_smallest(context_t) override;
@@ -592,7 +592,7 @@ class InternalNode final : public Node {
       return std::make_pair(Ref<Node>(node), mut);
     }
   };
-  static eagain_ifuture<fresh_node_t> allocate(context_t, laddr_t, field_type_t, bool, level_t);
+  static eagain_ifuture<fresh_node_t> allocate(context_t, laddr_hint_t, field_type_t, bool, level_t);
 
  private:
   /**
@@ -724,7 +724,7 @@ class LeafNode final : public Node {
       return std::make_pair(Ref<Node>(node), mut);
     }
   };
-  static eagain_ifuture<fresh_node_t> allocate(context_t, laddr_t, field_type_t, bool);
+  static eagain_ifuture<fresh_node_t> allocate(context_t, laddr_hint_t, field_type_t, bool);
 
  private:
   /**
index faf8bdf69b68df80a3e114a0e9f8f3649b6fc0b9..cda27e2d2171c933f06a2755a6989ea8ebab30bb 100644 (file)
@@ -512,7 +512,7 @@ class NodeExtentAccessorT {
     std::memcpy(to.get_write(), extent->get_read(), get_length());
   }
 
-  eagain_ifuture<NodeExtentMutable> rebuild(context_t c, laddr_t hint) {
+  eagain_ifuture<NodeExtentMutable> rebuild(context_t c, laddr_hint_t hint) {
     LOG_PREFIX(OTree::Extent::rebuild);
     assert(!is_retired());
     if (state == nextent_state_t::FRESH) {
index 668cfdb0c6553df2eaddbaec3d285ad4add37477..5e8132df5bd22601f2b61b3d01af1d00eb7fda67 100644 (file)
@@ -75,7 +75,7 @@ class NodeExtentManager {
 
   using alloc_iertr = base_iertr;
   virtual alloc_iertr::future<NodeExtentRef> alloc_extent(
-      Transaction&, laddr_t hint, extent_len_t) = 0;
+      Transaction&, laddr_hint_t hint, extent_len_t) = 0;
 
   using retire_iertr = base_iertr::extend<
     crimson::ct_error::enoent>;
index c01c820ad6f62d2c080823301abec101a3dfb557..6852ec0298c16fb634b557dc51525c65227d8e82 100644 (file)
@@ -89,7 +89,7 @@ class DummyNodeExtentManager final: public NodeExtentManager {
   }
 
   alloc_iertr::future<NodeExtentRef> alloc_extent(
-      Transaction& t, laddr_t hint, extent_len_t len) override {
+      Transaction& t, laddr_hint_t hint, extent_len_t len) override {
     SUBTRACET(seastore_onode, "allocating {}B with hint {} ...", t, len, hint);
     if constexpr (SYNC) {
       return alloc_extent_sync(t, len);
index dc5799382ba779a7b8446559e64ca872547970f6..a5d863c39896f31ce7154eeea8bc2728e9c7da7f 100644 (file)
@@ -133,7 +133,7 @@ class SeastoreNodeExtentManager final: public TransactionManagerHandle {
   }
 
   alloc_iertr::future<NodeExtentRef> alloc_extent(
-      Transaction& t, laddr_t hint, extent_len_t len) override {
+      Transaction& t, laddr_hint_t hint, extent_len_t len) override {
     SUBTRACET(seastore_onode, "allocating {}B with hint {} ...", t, len, hint);
     if constexpr (INJECT_EAGAIN) {
       if (trigger_eagain()) {
index 2bca3ddb3a19a62640924db88651befcd48ca3bc..8398fdde549b83a235bdd82d0983a14959b03389 100644 (file)
@@ -13,7 +13,7 @@ last_split_info_t last_split = {};
 // XXX: branchless allocation
 eagain_ifuture<InternalNodeImpl::fresh_impl_t>
 InternalNodeImpl::allocate(
-    context_t c, laddr_t hint, field_type_t type, bool is_level_tail, level_t level)
+    context_t c, laddr_hint_t hint, field_type_t type, bool is_level_tail, level_t level)
 {
   if (type == field_type_t::N0) {
     return InternalNode0::allocate(c, hint, is_level_tail, level);
@@ -30,7 +30,7 @@ InternalNodeImpl::allocate(
 
 eagain_ifuture<LeafNodeImpl::fresh_impl_t>
 LeafNodeImpl::allocate(
-    context_t c, laddr_t hint, field_type_t type, bool is_level_tail)
+    context_t c, laddr_hint_t hint, field_type_t type, bool is_level_tail)
 {
   if (type == field_type_t::N0) {
     return LeafNode0::allocate(c, hint, is_level_tail, 0);
index 0f99696accf7b3785810507c7d1bf79669fa2422..7abf5c8a574c15abf9b05287db9e086b940a8b55 100644 (file)
@@ -179,7 +179,7 @@ class InternalNodeImpl : public NodeImpl {
       return {std::move(impl), mut};
     }
   };
-  static eagain_ifuture<fresh_impl_t> allocate(context_t, laddr_t, field_type_t, bool, level_t);
+  static eagain_ifuture<fresh_impl_t> allocate(context_t, laddr_hint_t, field_type_t, bool, level_t);
 
   static InternalNodeImplURef load(NodeExtentRef, field_type_t);
 
@@ -259,7 +259,7 @@ class LeafNodeImpl : public NodeImpl {
       return {std::move(impl), mut};
     }
   };
-  static eagain_ifuture<fresh_impl_t> allocate(context_t, laddr_t, field_type_t, bool);
+  static eagain_ifuture<fresh_impl_t> allocate(context_t, laddr_hint_t, field_type_t, bool);
 
   static LeafNodeImplURef load(NodeExtentRef, field_type_t);
 
index d184d59aaa3136e181045d5a514ad31de879c2a8..8190cc40e2b548bff9e961b8d300e31e03325628 100644 (file)
@@ -67,7 +67,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl {
   }
 
   static eagain_ifuture<typename parent_t::fresh_impl_t> allocate(
-      context_t c, laddr_t hint, bool is_level_tail, level_t level) {
+      context_t c, laddr_hint_t hint, bool is_level_tail, level_t level) {
     LOG_PREFIX(OTree::Layout::allocate);
     extent_len_t extent_size;
     if constexpr (NODE_TYPE == node_type_t::LEAF) {
@@ -309,7 +309,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl {
     key_view_t first_index;
     stage_t::template get_slot<true, false>(
         extent.read(), position_t::begin(), &first_index, nullptr);
-    auto hint = first_index.get_hint();
+    auto hint = first_index.create_onode_hint();
     return extent.rebuild(c, hint).si_then([this] (auto mut) {
       // addr may change
       build_name();
index fd23efdde2d5f53646b0ea051b05bac104d04912..a86ec6770f22df567091d82ae59d3965f63feb6c 100644 (file)
@@ -32,7 +32,8 @@ struct onode_item_t {
   void initialize(Transaction& t, Onode& value) const {
     auto &ftvalue = static_cast<FLTreeOnode&>(value);
     ftvalue.update_onode_size(t, size);
-    auto oroot = omap_root_t(laddr_t::from_raw_uint(id), cnt_modify,
+    auto laddr = laddr_t::from_byte_offset(id << laddr_t::UNIT_SHIFT);
+    auto oroot = omap_root_t(laddr, cnt_modify,
       value.get_metadata_hint(block_size), omap_type_t::OMAP);
     ftvalue.update_omap_root(t, oroot);
     validate(value);
@@ -41,7 +42,8 @@ struct onode_item_t {
   void validate(Onode& value) const {
     auto& layout = value.get_layout();
     ceph_assert(uint64_t(layout.size) == uint64_t{size});
-    ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr_t::from_raw_uint(id));
+    auto laddr = laddr_t::from_byte_offset(id << laddr_t::UNIT_SHIFT);
+    ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).addr == laddr);
     ceph_assert(layout.omap_root.get(value.get_metadata_hint(block_size)).depth == cnt_modify);
   }
 
index 331467000362f3e8fd69241b3e29f21ec336c4c9..3a531f7de74e17a009af270241a3b64467530652 100644 (file)
@@ -38,12 +38,18 @@ using namespace crimson::os::seastore::onode;
     }                                   \
   )
 
-#define INTR_WITH_PARAM(fun, c, b, v)   \
-  with_trans_intr(                      \
-    c.t,                                \
-    [=] (auto &t) {                     \
-      return fun(c, L_ADDR_MIN, b, v);  \
-    }                                   \
+#define INTR_WITH_PARAM(fun, c, b, v)                           \
+  with_trans_intr(                                              \
+    c.t,                                                        \
+    [=] (auto &t) {                                             \
+      laddr_hint_t hint;                                        \
+      hint.addr = L_ADDR_MIN;                                   \
+      hint.condition =                                          \
+          laddr_conflict_condition_t::all_at_object_content;    \
+      hint.policy =                                             \
+          laddr_conflict_policy_t::linear_search;               \
+      return fun(c, hint, b, v);                                \
+    }                                                           \
   )
 
 namespace {
@@ -1061,7 +1067,12 @@ class DummyChildPool {
         crimson::ct_error::assert_all{"Invalid error during create_initial()"}
       ).si_then([c, initial](auto super) {
         initial->make_root_new(c, std::move(super));
-        return initial->upgrade_root(c, L_ADDR_MIN).si_then([initial] {
+        laddr_hint_t hint;
+        hint.addr = L_ADDR_MIN;
+        hint.condition = laddr_conflict_condition_t::all_at_object_content;
+        hint.policy = laddr_conflict_policy_t::linear_search;
+        hint.block_size = laddr_t::UNIT_SIZE;
+        return initial->upgrade_root(c, hint).si_then([initial] {
           return initial;
         });
       });