]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: remove child_pos in LBAMapping
authorXuehan Xu <xuxuehan@qianxin.com>
Mon, 21 Apr 2025 06:39:08 +0000 (14:39 +0800)
committerzs <zs@ijk.dev>
Tue, 20 May 2025 06:27:59 +0000 (14:27 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.cc
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.h
src/crimson/os/seastore/lba_mapping.h
src/crimson/os/seastore/transaction_manager.h

index f4c36b30312d8dd84fee69533536940ec074d31b..3dacacbc2590deef0b396cafb679daf38b014923 100644 (file)
@@ -99,11 +99,7 @@ BtreeLBAMapping::get_logical_extent(Transaction &t)
   auto k = this->is_indirect()
     ? this->get_intermediate_base()
     : get_key();
-  auto v = p.template get_child<LogicalChildNode>(ctx.trans, ctx.cache, pos, k);
-  if (!v.has_child()) {
-    this->child_pos = v.get_child_pos();
-  }
-  return v;
+  return p.template get_child<LogicalChildNode>(ctx.trans, ctx.cache, pos, k);
 }
 
 bool BtreeLBAMapping::is_stable() const
index 3dac0e5afe32748b7dfb8d20c753ff2c7110ec62..32261b6e79f42685c4c9a87a3a145f055c4abb9e 100644 (file)
@@ -84,11 +84,7 @@ public:
       raw_val(val.pladdr),
       map_val(val),
       parent_modifications(parent->modifications)
-  {
-    if (!parent->is_pending()) {
-      this->child_pos = {parent, pos};
-    }
-  }
+  {}
 
   lba_map_val_t get_map_val() const {
     return map_val;
index 1f3d4d53233d96fa1edad2987ebefd83de504bc8..ec79c57da43cafcdf881a46ab93633d202d07396 100644 (file)
@@ -84,10 +84,6 @@ public:
   virtual get_child_ret_t<lba_manager::btree::LBALeafNode, LogicalChildNode>
   get_logical_extent(Transaction &t) = 0;
 
-  void link_child(LogicalChildNode *c) {
-    ceph_assert(child_pos);
-    child_pos->link_child(c);
-  }
   virtual LBAMappingRef refresh_with_pending_parent() = 0;
 
   // For reserved mappings, the return values are
@@ -112,9 +108,6 @@ protected:
   extent_len_t len = 0;
   fixed_kv_node_meta_t<laddr_t> range;
   uint16_t pos = std::numeric_limits<uint16_t>::max();
-
-  std::optional<child_pos_t<
-    lba_manager::btree::LBALeafNode>> child_pos = std::nullopt;
 };
 
 std::ostream &operator<<(std::ostream &out, const LBAMapping &rhs);
index dd60fb8ac3cb17860b63a1af9810820e18d6180d..4fffcbc88f44aa8d2dcd5793655628a2e46efdd4 100644 (file)
@@ -311,8 +311,9 @@ public:
           return std::move(extent);
         });
       } else {
+       auto &r = std::get<0>(ret);
        return this->pin_to_extent<T>(
-          t, std::move(std::get<0>(ret)),
+          t, std::move(r.mapping), std::move(r.child_pos),
          direct_partial_off, partial_len,
          std::move(maybe_init));
       }
@@ -981,8 +982,13 @@ private:
 
   shard_stats_t& shard_stats;
 
+  using LBALeafNode = lba_manager::btree::LBALeafNode;
+  struct unlinked_child_t {
+    LBAMappingRef mapping;
+    child_pos_t<LBALeafNode> child_pos;
+  };
   template <typename T>
-  std::variant<LBAMappingRef, get_child_ifut<T>>
+  std::variant<unlinked_child_t, get_child_ifut<T>>
   get_extent_if_linked(
     Transaction &t,
     LBAMappingRef pin)
@@ -1005,7 +1011,9 @@ private:
        return extent->template cast<T>();
       });
     } else {
-      return pin;
+      return unlinked_child_t{
+       std::move(pin),
+       v.get_child_pos()};
     }
   }
 
@@ -1027,7 +1035,7 @@ private:
         return ext;
       });
     } else {
-      return pin_to_extent_by_type(t, std::move(pin), type);
+      return pin_to_extent_by_type(t, std::move(pin), v.get_child_pos(), type);
     }
   }
 
@@ -1059,6 +1067,7 @@ private:
   pin_to_extent_ret<T> pin_to_extent(
     Transaction &t,
     LBAMappingRef pin,
+    child_pos_t<LBALeafNode> child_pos,
     extent_len_t direct_partial_off,
     extent_len_t partial_len,
     lextent_init_func_t<T> &&maybe_init) {
@@ -1083,14 +1092,15 @@ private:
       direct_length,
       direct_partial_off,
       partial_len,
-      [&pref, maybe_init=std::move(maybe_init)]
+      [&pref, maybe_init=std::move(maybe_init),
+       child_pos=std::move(child_pos)]
       (T &extent) mutable {
        assert(extent.is_logical());
        assert(!extent.has_laddr());
        assert(!extent.has_been_invalidated());
        assert(!pref.has_been_invalidated());
        assert(pref.get_parent());
-       pref.link_child(&extent);
+       child_pos.link_child(&extent);
        extent.maybe_set_intermediate_laddr(pref);
        maybe_init(extent);
        extent.set_seen_by_users();
@@ -1140,6 +1150,7 @@ private:
   pin_to_extent_by_type_ret pin_to_extent_by_type(
       Transaction &t,
       LBAMappingRef pin,
+      child_pos_t<LBALeafNode> child_pos,
       extent_types_t type)
   {
     LOG_PREFIX(TransactionManager::pin_to_extent_by_type);
@@ -1163,7 +1174,7 @@ private:
       pref.get_val(),
       direct_key,
       direct_length,
-      [&pref](CachedExtent &extent) mutable {
+      [&pref, child_pos=std::move(child_pos)](CachedExtent &extent) mutable {
        assert(extent.is_logical());
        auto &lextent = static_cast<LogicalChildNode&>(extent);
        assert(!lextent.has_laddr());
@@ -1171,7 +1182,7 @@ private:
        assert(!pref.has_been_invalidated());
        assert(pref.get_parent());
        assert(!pref.get_parent()->is_pending());
-       pref.link_child(&lextent);
+       child_pos.link_child(&lextent);
        lextent.maybe_set_intermediate_laddr(pref);
         // No change to extent::seen_by_user because this path is only
         // for background cleaning.