]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/btree: clean up `FixedKVLeafNode::get_logical_child()` 56383/head
authorXuehan Xu <xuxuehan@qianxin.com>
Fri, 22 Mar 2024 07:22:46 +0000 (15:22 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Mon, 8 Apr 2024 02:27:04 +0000 (10:27 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/btree/btree_range_pin.cc
src/crimson/os/seastore/btree/fixed_kv_node.h

index 3da1cac970ae74bb603effa21b79293927ce9dca..81d9c4116fd659c1cb9c79e29d53dc8ce18e5f53 100644 (file)
@@ -15,7 +15,10 @@ BtreeNodeMapping<key_t, val_t>::get_logical_extent(
   assert(parent->is_valid());
   assert(pos != std::numeric_limits<uint16_t>::max());
   auto &p = (FixedKVNode<key_t>&)*parent;
-  auto v = p.get_logical_child(ctx, pos);
+  auto k = this->is_indirect()
+    ? this->get_intermediate_base()
+    : get_key();
+  auto v = p.template get_child<LogicalCachedExtent>(ctx, pos, k);
   if (!v.has_child()) {
     this->child_pos = v.get_child_pos();
   }
index ab8775ad8aa8308cb934fe4da94851817015cc09..e9ffeed452ee13de5eca9b834e0c2580833cf8cc 100644 (file)
@@ -226,27 +226,24 @@ struct FixedKVNode : ChildableCachedExtent {
     set_child_ptracker(child);
   }
 
-  virtual get_child_ret_t<LogicalCachedExtent>
-  get_logical_child(op_context_t<node_key_t> c, uint16_t pos) = 0;
-
   virtual bool is_child_stable(op_context_t<node_key_t>, uint16_t pos) const = 0;
 
-  template <typename T, typename iter_t>
-  get_child_ret_t<T> get_child(op_context_t<node_key_t> c, iter_t iter) {
-    auto pos = iter.get_offset();
+  template <typename T>
+  get_child_ret_t<T> get_child(
+    op_context_t<node_key_t> c,
+    uint16_t pos,
+    node_key_t key)
+  {
     assert(children.capacity());
     auto child = children[pos];
     ceph_assert(!is_reserved_ptr(child));
     if (is_valid_child_ptr(child)) {
-      ceph_assert(child->get_type() == T::TYPE);
       return c.cache.template get_extent_viewable_by_trans<T>(c.trans, (T*)child);
     } else if (is_pending()) {
-      auto key = iter.get_key();
       auto &sparent = get_stable_for_key(key);
       auto spos = sparent.child_pos_for_key(key);
       auto child = sparent.children[spos];
       if (is_valid_child_ptr(child)) {
-       ceph_assert(child->get_type() == T::TYPE);
        return c.cache.template get_extent_viewable_by_trans<T>(c.trans, (T*)child);
       } else {
        return child_pos_t(&sparent, spos);
@@ -256,6 +253,11 @@ struct FixedKVNode : ChildableCachedExtent {
     }
   }
 
+  template <typename T, typename iter_t>
+  get_child_ret_t<T> get_child(op_context_t<node_key_t> c, iter_t iter) {
+    return get_child<T>(c, iter.get_offset(), iter.get_key());
+  }
+
   void split_child_ptrs(
     FixedKVNode &left,
     FixedKVNode &right)
@@ -591,12 +593,6 @@ struct FixedKVInternalNode
     }
   }
 
-  get_child_ret_t<LogicalCachedExtent>
-  get_logical_child(op_context_t<NODE_KEY>, uint16_t pos) final {
-    ceph_abort("impossible");
-    return get_child_ret_t<LogicalCachedExtent>(child_pos_t(nullptr, 0));
-  }
-
   bool is_child_stable(op_context_t<NODE_KEY>, uint16_t pos) const final {
     ceph_abort("impossible");
     return false;
@@ -970,31 +966,6 @@ struct FixedKVLeafNode
     return this->get_split_pivot().get_offset();
   }
 
-  get_child_ret_t<LogicalCachedExtent>
-  get_logical_child(op_context_t<NODE_KEY> c, uint16_t pos) final {
-    auto child = this->children[pos];
-    ceph_assert(!is_reserved_ptr(child));
-    if (is_valid_child_ptr(child)) {
-      ceph_assert(child->is_logical());
-      return c.cache.template get_extent_viewable_by_trans<
-       LogicalCachedExtent>(c.trans, (LogicalCachedExtent*)child);
-    } else if (this->is_pending()) {
-      auto key = this->iter_idx(pos).get_key();
-      auto &sparent = this->get_stable_for_key(key);
-      auto spos = sparent.child_pos_for_key(key);
-      auto child = sparent.children[spos];
-      if (is_valid_child_ptr(child)) {
-       ceph_assert(child->is_logical());
-       return c.cache.template get_extent_viewable_by_trans<
-         LogicalCachedExtent>(c.trans, (LogicalCachedExtent*)child);
-      } else {
-       return child_pos_t(&sparent, spos);
-      }
-    } else {
-      return child_pos_t(this, pos);
-    }
-  }
-
   // children are considered stable if any of the following case is true:
   // 1. The child extent is absent in cache
   // 2. The child extent is stable