From cb306cae7bd295ef43bf1b7618f13b410b60168a Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 24 Aug 2022 13:13:40 +0800 Subject: [PATCH] crimson/os: use IsFullKey in staged::insert_size{,at}() to fade out KeyT, so we can have more straightforward definitions. Signed-off-by: Kefu Chai --- .../onode_manager/staged-fltree/node_layout.h | 4 +-- .../staged-fltree/stages/stage.h | 28 +++++++-------- .../onode_manager/staged-fltree/value.cc | 8 ++--- .../seastore/onode_tree/test_staged_fltree.cc | 36 +++++++++---------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_layout.h b/src/crimson/os/seastore/onode_manager/staged-fltree/node_layout.h index 5f3b35de05d..85487944ee3 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_layout.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_layout.h @@ -871,7 +871,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl { if (unlikely(is_keys_empty())) { assert(insert_pos.is_end()); insert_stage = STAGE; - insert_size = stage_t::template insert_size(key, value); + insert_size = stage_t::insert_size(key, value); } else { std::tie(insert_stage, insert_size) = stage_t::evaluate_insert( node_stage, key, value, cast_down(insert_pos), false); @@ -893,7 +893,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl { if (unlikely(is_keys_empty())) { assert(insert_pos.is_end()); assert(is_level_tail()); - return {STAGE, stage_t::template insert_size(key, value)}; + return {STAGE, stage_t::insert_size(key, value)}; } else { return stage_t::evaluate_insert( key, value, history, mstat, cast_down(insert_pos)); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/stage.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/stage.h index f61a2390de3..5129695b644 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/stage.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/stage.h @@ -1133,27 +1133,27 @@ struct staged { } } - template - static node_offset_t insert_size(const full_key_t& key, + template + static node_offset_t insert_size(const Key& key, const value_input_t& value) { if constexpr (IS_BOTTOM) { return iterator_t::estimate_insert(key, value); } else { return iterator_t::estimate_insert(key, value) + NXT_STAGE_T::iterator_t::header_size() + - NXT_STAGE_T::template insert_size(key, value); + NXT_STAGE_T::insert_size(key, value); } } - template + template static node_offset_t insert_size_at(match_stage_t stage, - const full_key_t& key, + const Key& key, const value_input_t& value) { if (stage == STAGE) { - return insert_size(key, value); + return insert_size(key, value); } else { assert(stage < STAGE); - return NXT_STAGE_T::template insert_size_at(stage, key, value); + return NXT_STAGE_T::template insert_size_at(stage, key, value); } } @@ -1185,7 +1185,7 @@ struct staged { assert(match == std::strong_ordering::less); if (index == 0) { // already the first index, so insert at the current index - return {STAGE, insert_size(key, value)}; + return {STAGE, insert_size(key, value)}; } --index; iter = iterator_t(container); @@ -1199,7 +1199,7 @@ struct staged { if (match == std::strong_ordering::greater) { // key doesn't match both indexes, so insert at the current index ++index; - return {STAGE, insert_size(key, value)}; + return {STAGE, insert_size(key, value)}; } else { assert(match == std::strong_ordering::equal); if constexpr (IS_BOTTOM) { @@ -1296,7 +1296,7 @@ struct staged { patch_insert_end(position, insert_stage); } - node_offset_t insert_size = insert_size_at(insert_stage, key, value); + node_offset_t insert_size = insert_size_at(insert_stage, key, value); return {insert_stage, insert_size}; } @@ -1349,7 +1349,7 @@ struct staged { if (iter.is_end()) { // insert at the higher stage due to split do_insert = true; - _insert_size = insert_size(key, value); + _insert_size = insert_size(key, value); stage = STAGE; } } else { @@ -1361,7 +1361,7 @@ struct staged { if constexpr (!IS_BOTTOM) { position.nxt = position_t::nxt_t::begin(); } - assert(_insert_size == insert_size(key, value)); + assert(_insert_size == insert_size(key, value)); if constexpr (IS_BOTTOM) { return iter.insert( mut, key, value, _insert_size, p_left_bound); @@ -1394,11 +1394,11 @@ struct staged { if (position.is_end()) { position = position_t::begin(); assert(stage == STAGE); - assert(_insert_size == insert_size(key, value)); + assert(_insert_size == insert_size(key, value)); } else if (position == position_t::begin()) { // when insert into a trimmed and empty left node stage = STAGE; - _insert_size = insert_size(key, value); + _insert_size = insert_size(key, value); } else { ceph_abort("impossible path"); } diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc index e71ce06453a..694480d4ead 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/value.cc @@ -140,9 +140,9 @@ void validate_tree_config(const tree_conf_t& conf) laddr_t i_value{0}; auto insert_size_2 = - _STAGE_T(InternalNode0)::template insert_size(key, i_value); + _STAGE_T(InternalNode0)::insert_size(key, i_value); auto insert_size_0 = - NXT_T(NXT_T(_STAGE_T(InternalNode0)))::template insert_size(key, i_value); + NXT_T(NXT_T(_STAGE_T(InternalNode0)))::insert_size(key, i_value); unsigned internal_size_bound = sizeof(node_header_t) + (insert_size_2 + max_str_size) * 2 + (insert_size_2 - insert_size_0 + max_str_size); @@ -151,9 +151,9 @@ void validate_tree_config(const tree_conf_t& conf) value_config_t l_value; l_value.payload_size = conf.max_value_payload_size; insert_size_2 = - _STAGE_T(LeafNode0)::template insert_size(key, l_value); + _STAGE_T(LeafNode0)::insert_size(key, l_value); insert_size_0 = - NXT_T(NXT_T(_STAGE_T(LeafNode0)))::template insert_size(key, l_value); + NXT_T(NXT_T(_STAGE_T(LeafNode0)))::insert_size(key, l_value); unsigned leaf_size_bound = sizeof(node_header_t) + (insert_size_2 + max_str_size) * 2 + (insert_size_2 - insert_size_0 + max_str_size); diff --git a/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc b/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc index 437199c056e..26461b87f04 100644 --- a/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc +++ b/src/test/crimson/seastore/onode_tree/test_staged_fltree.cc @@ -139,24 +139,24 @@ TEST_F(a_basic_test_t, 1_basic_sizes) " LeafNode1: {} {} {}\n" " LeafNode2: {} {}\n" " LeafNode3: {}", - _STAGE_T(InternalNode0)::template insert_size(key_view, i_value), - NXT_T(_STAGE_T(InternalNode0))::template insert_size(key_view, i_value), - NXT_T(NXT_T(_STAGE_T(InternalNode0)))::template insert_size(key_view, i_value), - _STAGE_T(InternalNode1)::template insert_size(key_view, i_value), - NXT_T(_STAGE_T(InternalNode1))::template insert_size(key_view, i_value), - NXT_T(NXT_T(_STAGE_T(InternalNode1)))::template insert_size(key_view, i_value), - _STAGE_T(InternalNode2)::template insert_size(key_view, i_value), - NXT_T(_STAGE_T(InternalNode2))::template insert_size(key_view, i_value), - _STAGE_T(InternalNode3)::template insert_size(key_view, i_value), - _STAGE_T(LeafNode0)::template insert_size(key, value), - NXT_T(_STAGE_T(LeafNode0))::template insert_size(key, value), - NXT_T(NXT_T(_STAGE_T(LeafNode0)))::template insert_size(key, value), - _STAGE_T(LeafNode1)::template insert_size(key, value), - NXT_T(_STAGE_T(LeafNode1))::template insert_size(key, value), - NXT_T(NXT_T(_STAGE_T(LeafNode1)))::template insert_size(key, value), - _STAGE_T(LeafNode2)::template insert_size(key, value), - NXT_T(_STAGE_T(LeafNode2))::template insert_size(key, value), - _STAGE_T(LeafNode3)::template insert_size(key, value) + _STAGE_T(InternalNode0)::insert_size(key_view, i_value), + NXT_T(_STAGE_T(InternalNode0))::insert_size(key_view, i_value), + NXT_T(NXT_T(_STAGE_T(InternalNode0)))::insert_size(key_view, i_value), + _STAGE_T(InternalNode1)::insert_size(key_view, i_value), + NXT_T(_STAGE_T(InternalNode1))::insert_size(key_view, i_value), + NXT_T(NXT_T(_STAGE_T(InternalNode1)))::insert_size(key_view, i_value), + _STAGE_T(InternalNode2)::insert_size(key_view, i_value), + NXT_T(_STAGE_T(InternalNode2))::insert_size(key_view, i_value), + _STAGE_T(InternalNode3)::insert_size(key_view, i_value), + _STAGE_T(LeafNode0)::insert_size(key, value), + NXT_T(_STAGE_T(LeafNode0))::insert_size(key, value), + NXT_T(NXT_T(_STAGE_T(LeafNode0)))::insert_size(key, value), + _STAGE_T(LeafNode1)::insert_size(key, value), + NXT_T(_STAGE_T(LeafNode1))::insert_size(key, value), + NXT_T(NXT_T(_STAGE_T(LeafNode1)))::insert_size(key, value), + _STAGE_T(LeafNode2)::insert_size(key, value), + NXT_T(_STAGE_T(LeafNode2))::insert_size(key, value), + _STAGE_T(LeafNode3)::insert_size(key, value) ); std::free(p_mem); }