From: Kefu Chai Date: Thu, 18 Aug 2022 15:10:21 +0000 (+0800) Subject: crimson: define encode_key() with IsFullKey constrait X-Git-Tag: v18.0.0~233^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d143757d24ad7cf6fb3bdc34b0947ca50785a6ac;p=ceph.git crimson: define encode_key() with IsFullKey constrait also, let the compiler to deduce the type of the template parameter, less repeating and less error-prone this way. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h index aae6018074be8..1bd532c4ac1b7 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h @@ -42,7 +42,7 @@ class DeltaRecorderT final: public DeltaRecorder { const match_stage_t& insert_stage, const node_offset_t& insert_size) { ceph::encode(node_delta_op_t::INSERT, encoded); - encode_key(key, encoded); + encode_key(key, encoded); encode_value(value, encoded); insert_pos.encode(encoded); ceph::encode(insert_stage, encoded); @@ -67,7 +67,7 @@ class DeltaRecorderT final: public DeltaRecorder { const char* p_node_start) { ceph::encode(node_delta_op_t::SPLIT_INSERT, encoded); split_at.encode(p_node_start, encoded); - encode_key(key, encoded); + encode_key(key, encoded); encode_value(value, encoded); insert_pos.encode(encoded); ceph::encode(insert_stage, encoded); diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h index 5309e9a111b84..b2224455c8be4 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h @@ -733,8 +733,11 @@ class key_view_t { const snap_gen_t* p_snap_gen = nullptr; }; -template -void encode_key(const full_key_t& key, ceph::bufferlist& bl) { +template +concept IsFullKey = std::same_as || std::same_as; + +template +void encode_key(const Key& key, ceph::bufferlist& bl) { ceph::encode(key.shard(), bl); ceph::encode(key.pool(), bl); ceph::encode(key.crush(), bl); @@ -744,9 +747,6 @@ void encode_key(const full_key_t& key, ceph::bufferlist& bl) { ceph::encode(key.gen(), bl); } -template -concept IsFullKey = std::same_as || std::same_as; - template std::strong_ordering operator<=>(const LHS& lhs, const RHS& rhs) noexcept { auto ret = lhs.shard() <=> rhs.shard();