From ad0ce3a04b9b32a2c2ce5ce32bc093c923742b09 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Aug 2022 21:50:28 +0800 Subject: [PATCH] crimson/os: use IsFullKey in *::insert_prefix{,_at}() to fade out KeyT, so we can have more straightforward definitions. Signed-off-by: Kefu Chai --- .../stages/item_iterator_stage.cc | 18 +++++----- .../stages/item_iterator_stage.h | 4 +-- .../staged-fltree/stages/node_stage.cc | 34 +++++++++---------- .../staged-fltree/stages/node_stage.h | 8 ++--- .../staged-fltree/stages/stage.h | 20 +++++------ .../staged-fltree/stages/sub_items_stage.cc | 22 ++++++------ .../staged-fltree/stages/sub_items_stage.h | 8 ++--- 7 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc index 165d61a96a9..9252fb99a44 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.cc @@ -11,9 +11,9 @@ namespace crimson::os::seastore::onode { #define ITER_INST(NT) item_iterator_t template -template +template memory_range_t ITER_T::insert_prefix( - NodeExtentMutable& mut, const ITER_T& iter, const full_key_t& key, + NodeExtentMutable& mut, const ITER_T& iter, const Key& key, bool is_end, node_offset_t size, const char* p_left_bound) { // 1. insert range @@ -41,14 +41,14 @@ memory_range_t ITER_T::insert_prefix( return {p_insert_front, p_insert}; } -#define IP_TEMPLATE(NT, KT) \ - template memory_range_t ITER_INST(NT)::insert_prefix( \ - NodeExtentMutable&, const ITER_INST(NT)&, const full_key_t&, \ +#define IP_TEMPLATE(NT, Key) \ + template memory_range_t ITER_INST(NT)::insert_prefix( \ + NodeExtentMutable&, const ITER_INST(NT)&, const Key&, \ bool, node_offset_t, const char*) -IP_TEMPLATE(node_type_t::LEAF, KeyT::VIEW); -IP_TEMPLATE(node_type_t::INTERNAL, KeyT::VIEW); -IP_TEMPLATE(node_type_t::LEAF, KeyT::HOBJ); -IP_TEMPLATE(node_type_t::INTERNAL, KeyT::HOBJ); +IP_TEMPLATE(node_type_t::LEAF, key_view_t); +IP_TEMPLATE(node_type_t::INTERNAL, key_view_t); +IP_TEMPLATE(node_type_t::LEAF, key_hobj_t); +IP_TEMPLATE(node_type_t::INTERNAL, key_hobj_t); template void ITER_T::update_size( diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.h index 4f945b727c6..9d12474acab 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/item_iterator_stage.h @@ -132,10 +132,10 @@ class item_iterator_t { return ns_oid_view_t::estimate_size(key) + sizeof(node_offset_t); } - template + template static memory_range_t insert_prefix( NodeExtentMutable& mut, const item_iterator_t& iter, - const full_key_t& key, bool is_end, + const Key& key, bool is_end, node_offset_t size, const char* p_left_bound); static void update_size( diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc index 95855943fc2..3ed401c3751 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.cc @@ -91,9 +91,9 @@ void NODE_T::update_is_level_tail( } template -template +template memory_range_t NODE_T::insert_prefix_at( - NodeExtentMutable& mut, const node_extent_t& node, const full_key_t& key, + NodeExtentMutable& mut, const node_extent_t& node, const Key& key, index_t index, node_offset_t size, const char* p_left_bound) { assert(mut.get_length() == node.node_size); @@ -118,22 +118,22 @@ memory_range_t NODE_T::insert_prefix_at( ceph_abort("impossible"); } } -#define IPA_TEMPLATE(FT, NT, KT) \ - template memory_range_t NODE_INST(FT, NT)::insert_prefix_at( \ - NodeExtentMutable&, const node_extent_t&, const full_key_t&, \ +#define IPA_TEMPLATE(FT, NT, Key) \ + template memory_range_t NODE_INST(FT, NT)::insert_prefix_at( \ + NodeExtentMutable&, const node_extent_t&, const Key&, \ index_t, node_offset_t, const char*) -IPA_TEMPLATE(node_fields_0_t, node_type_t::INTERNAL, KeyT::VIEW); -IPA_TEMPLATE(node_fields_1_t, node_type_t::INTERNAL, KeyT::VIEW); -IPA_TEMPLATE(node_fields_2_t, node_type_t::INTERNAL, KeyT::VIEW); -IPA_TEMPLATE(node_fields_0_t, node_type_t::LEAF, KeyT::VIEW); -IPA_TEMPLATE(node_fields_1_t, node_type_t::LEAF, KeyT::VIEW); -IPA_TEMPLATE(node_fields_2_t, node_type_t::LEAF, KeyT::VIEW); -IPA_TEMPLATE(node_fields_0_t, node_type_t::INTERNAL, KeyT::HOBJ); -IPA_TEMPLATE(node_fields_1_t, node_type_t::INTERNAL, KeyT::HOBJ); -IPA_TEMPLATE(node_fields_2_t, node_type_t::INTERNAL, KeyT::HOBJ); -IPA_TEMPLATE(node_fields_0_t, node_type_t::LEAF, KeyT::HOBJ); -IPA_TEMPLATE(node_fields_1_t, node_type_t::LEAF, KeyT::HOBJ); -IPA_TEMPLATE(node_fields_2_t, node_type_t::LEAF, KeyT::HOBJ); +IPA_TEMPLATE(node_fields_0_t, node_type_t::INTERNAL, key_view_t); +IPA_TEMPLATE(node_fields_1_t, node_type_t::INTERNAL, key_view_t); +IPA_TEMPLATE(node_fields_2_t, node_type_t::INTERNAL, key_view_t); +IPA_TEMPLATE(node_fields_0_t, node_type_t::LEAF, key_view_t); +IPA_TEMPLATE(node_fields_1_t, node_type_t::LEAF, key_view_t); +IPA_TEMPLATE(node_fields_2_t, node_type_t::LEAF, key_view_t); +IPA_TEMPLATE(node_fields_0_t, node_type_t::INTERNAL, key_hobj_t); +IPA_TEMPLATE(node_fields_1_t, node_type_t::INTERNAL, key_hobj_t); +IPA_TEMPLATE(node_fields_2_t, node_type_t::INTERNAL, key_hobj_t); +IPA_TEMPLATE(node_fields_0_t, node_type_t::LEAF, key_hobj_t); +IPA_TEMPLATE(node_fields_1_t, node_type_t::LEAF, key_hobj_t); +IPA_TEMPLATE(node_fields_2_t, node_type_t::LEAF, key_hobj_t); template void NODE_T::update_size_at( diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.h index b00539fd041..5615998f8f8 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage.h @@ -146,10 +146,10 @@ class node_extent_t { return size; } - template + template static const value_t* insert_at( NodeExtentMutable& mut, const node_extent_t&, - const full_key_t& key, const value_input_t& value, + const Key& key, const value_input_t& value, index_t index, node_offset_t size, const char* p_left_bound) { if constexpr (FIELD_TYPE == field_type_t::N3) { ceph_abort("not implemented"); @@ -158,10 +158,10 @@ class node_extent_t { } } - template + template static memory_range_t insert_prefix_at( NodeExtentMutable&, const node_extent_t&, - const full_key_t& key, + const Key& key, index_t index, node_offset_t size, const char* p_left_bound); static void update_size_at( 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 0a8e87bc7e4..6e954aa29d2 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 @@ -323,15 +323,15 @@ struct staged { const value_input_t& value, node_offset_t insert_size, const char* p_left_bound) { - return container_t::template insert_at( + return container_t::insert_at( mut, container, key, value, _index, insert_size, p_left_bound); } - template + template std::enable_if_t insert_prefix( - NodeExtentMutable& mut, const full_key_t& key, + NodeExtentMutable& mut, const Key& key, node_offset_t size, const char* p_left_bound) { - return container_t::template insert_prefix_at( + return container_t::insert_prefix_at( mut, container, key, _index, size, p_left_bound); } @@ -647,11 +647,11 @@ struct staged { return MatchKindBS::NE; } - template + template memory_range_t insert_prefix( - NodeExtentMutable& mut, const full_key_t& key, + NodeExtentMutable& mut, const Key& key, node_offset_t size, const char* p_left_bound) { - return container_t::template insert_prefix( + return container_t::insert_prefix( mut, container, key, is_end(), size, p_left_bound); } @@ -1366,7 +1366,7 @@ struct staged { return iter.template insert( mut, key, value, _insert_size, p_left_bound); } else { - auto range = iter.template insert_prefix( + auto range = iter.insert_prefix( mut, key, _insert_size, p_left_bound); return NXT_STAGE_T::template insert_new(mut, range, key, value); } @@ -1403,10 +1403,10 @@ struct staged { ceph_abort("impossible path"); } if constexpr (IS_BOTTOM) { - return container_t::template insert_at( + return container_t::insert_at( mut, container, key, value, 0, _insert_size, p_left_bound); } else { - auto range = container_t::template insert_prefix_at( + auto range = container_t::template insert_prefix_at( mut, container, key, 0, _insert_size, p_left_bound); return NXT_STAGE_T::template insert_new(mut, range, key, value); } diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc index 2d37467a92b..28e6f7102c2 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.cc @@ -7,10 +7,10 @@ namespace crimson::os::seastore::onode { -template +template const laddr_packed_t* internal_sub_items_t::insert_at( NodeExtentMutable& mut, const internal_sub_items_t& sub_items, - const full_key_t& key, const laddr_t& value, + const Key& key, const laddr_t& value, index_t index, node_offset_t size, const char* p_left_bound) { assert(index <= sub_items.keys()); @@ -26,12 +26,12 @@ const laddr_packed_t* internal_sub_items_t::insert_at( mut.copy_in_absolute(p_insert, item); return &reinterpret_cast(p_insert)->value; } -#define IA_TEMPLATE(KT) \ - template const laddr_packed_t* internal_sub_items_t::insert_at( \ - NodeExtentMutable&, const internal_sub_items_t&, const full_key_t&, \ +#define IA_TEMPLATE(Key) \ + template const laddr_packed_t* internal_sub_items_t::insert_at( \ + NodeExtentMutable&, const internal_sub_items_t&, const Key&, \ const laddr_t&, index_t, node_offset_t, const char*) -IA_TEMPLATE(KeyT::VIEW); -IA_TEMPLATE(KeyT::HOBJ); +IA_TEMPLATE(key_view_t); +IA_TEMPLATE(key_hobj_t); node_offset_t internal_sub_items_t::trim_until( NodeExtentMutable& mut, internal_sub_items_t& items, index_t index) @@ -84,10 +84,10 @@ void internal_sub_items_t::Appender::append( p_value = &reinterpret_cast(p_append)->value; } -template +template const value_header_t* leaf_sub_items_t::insert_at( NodeExtentMutable& mut, const leaf_sub_items_t& sub_items, - const full_key_t& key, const value_config_t& value, + const Key& key, const value_config_t& value, index_t index, node_offset_t size, const char* p_left_bound) { assert(index <= sub_items.keys()); @@ -130,8 +130,8 @@ const value_header_t* leaf_sub_items_t::insert_at( return p_value; } -template const value_header_t* leaf_sub_items_t::insert_at( - NodeExtentMutable&, const leaf_sub_items_t&, const full_key_t&, +template const value_header_t* leaf_sub_items_t::insert_at( + NodeExtentMutable&, const leaf_sub_items_t&, const key_hobj_t&, const value_config_t&, index_t, node_offset_t, const char*); node_offset_t leaf_sub_items_t::trim_until( diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.h index ed07dc76340..e3d1fd7c5b7 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/sub_items_stage.h @@ -109,10 +109,10 @@ class internal_sub_items_t { return sizeof(internal_sub_item_t); } - template + template static const laddr_packed_t* insert_at( NodeExtentMutable&, const internal_sub_items_t&, - const full_key_t&, const laddr_t&, + const Key&, const laddr_t&, index_t index, node_offset_t size, const char* p_left_bound); static node_offset_t trim_until(NodeExtentMutable&, internal_sub_items_t&, index_t); @@ -289,10 +289,10 @@ class leaf_sub_items_t { return value.allocation_size() + sizeof(snap_gen_t) + sizeof(node_offset_t); } - template + template static const value_header_t* insert_at( NodeExtentMutable&, const leaf_sub_items_t&, - const full_key_t&, const value_config_t&, + const Key&, const value_config_t&, index_t index, node_offset_t size, const char* p_left_bound); static node_offset_t trim_until(NodeExtentMutable&, leaf_sub_items_t&, index_t index); -- 2.39.5