From: Xuehan Xu Date: Fri, 22 Mar 2024 07:22:46 +0000 (+0800) Subject: crimson/os/seastore/btree: clean up `FixedKVLeafNode::get_logical_child()` X-Git-Tag: v20.0.0~2195^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6e4f52a8ff93484d156f1d9095608a55e9c46aed;p=ceph.git crimson/os/seastore/btree: clean up `FixedKVLeafNode::get_logical_child()` Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/os/seastore/btree/btree_range_pin.cc b/src/crimson/os/seastore/btree/btree_range_pin.cc index 3da1cac970ae7..81d9c4116fd65 100644 --- a/src/crimson/os/seastore/btree/btree_range_pin.cc +++ b/src/crimson/os/seastore/btree/btree_range_pin.cc @@ -15,7 +15,10 @@ BtreeNodeMapping::get_logical_extent( assert(parent->is_valid()); assert(pos != std::numeric_limits::max()); auto &p = (FixedKVNode&)*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(ctx, pos, k); if (!v.has_child()) { this->child_pos = v.get_child_pos(); } diff --git a/src/crimson/os/seastore/btree/fixed_kv_node.h b/src/crimson/os/seastore/btree/fixed_kv_node.h index ab8775ad8aa83..e9ffeed452ee1 100644 --- a/src/crimson/os/seastore/btree/fixed_kv_node.h +++ b/src/crimson/os/seastore/btree/fixed_kv_node.h @@ -226,27 +226,24 @@ struct FixedKVNode : ChildableCachedExtent { set_child_ptracker(child); } - virtual get_child_ret_t - get_logical_child(op_context_t c, uint16_t pos) = 0; - virtual bool is_child_stable(op_context_t, uint16_t pos) const = 0; - template - get_child_ret_t get_child(op_context_t c, iter_t iter) { - auto pos = iter.get_offset(); + template + get_child_ret_t get_child( + op_context_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(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(c.trans, (T*)child); } else { return child_pos_t(&sparent, spos); @@ -256,6 +253,11 @@ struct FixedKVNode : ChildableCachedExtent { } } + template + get_child_ret_t get_child(op_context_t c, iter_t iter) { + return get_child(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 - get_logical_child(op_context_t, uint16_t pos) final { - ceph_abort("impossible"); - return get_child_ret_t(child_pos_t(nullptr, 0)); - } - bool is_child_stable(op_context_t, 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 - get_logical_child(op_context_t 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