From: Myoungwon Oh Date: Mon, 25 Nov 2024 09:58:07 +0000 (+0000) Subject: crimson/os/seastore: allocate OMapLeafNode depending on the type X-Git-Tag: v20.0.0~24^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=082c90006ec4b666aecd3cd56fef977c895213f2;p=ceph.git crimson/os/seastore: allocate OMapLeafNode depending on the type Signed-off-by: Myoungwon Oh --- diff --git a/src/crimson/os/seastore/omap_manager.h b/src/crimson/os/seastore/omap_manager.h index e398b18d1fc..e017f8d7be2 100644 --- a/src/crimson/os/seastore/omap_manager.h +++ b/src/crimson/os/seastore/omap_manager.h @@ -18,6 +18,7 @@ // and return errors during insert if the max is exceeded. #define OMAP_INNER_BLOCK_SIZE 8192 #define OMAP_LEAF_BLOCK_SIZE 65536 +#define LOG_LEAF_BLOCK_SIZE 16384 namespace crimson::os::seastore { diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc index 1e4afffaf7b..6b5a452ab92 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc @@ -23,7 +23,7 @@ BtreeOMapManager::initialize_omap(Transaction &t, laddr_t hint, { LOG_PREFIX(BtreeOMapManager::initialize_omap); DEBUGT("hint: {}", t, hint); - return tm.alloc_non_data_extent(t, hint, OMAP_LEAF_BLOCK_SIZE) + return tm.alloc_non_data_extent(t, hint, get_leaf_size(type)) .si_then([hint, &t, type](auto&& root_extent) { root_extent->set_size(0); omap_node_meta_t meta{1}; diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h index db6ba5ea531..5f70d565c1e 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h @@ -106,6 +106,14 @@ public: omap_root_t &omap_root, Transaction &t) final; + static extent_len_t get_leaf_size(omap_type_t type) { + if (type == omap_type_t::LOG) { + return LOG_LEAF_BLOCK_SIZE; + } + ceph_assert(type == omap_type_t::OMAP || + type == omap_type_t::XATTR); + return OMAP_LEAF_BLOCK_SIZE; + } }; using BtreeOMapManagerRef = std::unique_ptr; diff --git a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc index df97f394a0d..5ba964ee99a 100644 --- a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc +++ b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc @@ -673,7 +673,7 @@ OMapLeafNode::make_split_children(omap_context_t oc) { LOG_PREFIX(OMapLeafNode::make_split_children); DEBUGT("this: {}", oc.t, *this); - return oc.tm.alloc_extents(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2) + return oc.tm.alloc_extents(oc.t, oc.hint, get_len(), 2) .si_then([this] (auto &&ext_pair) { auto left = ext_pair.front(); auto right = ext_pair.back(); @@ -692,7 +692,7 @@ OMapLeafNode::make_full_merge(omap_context_t oc, OMapNodeRef right) ceph_assert(right->get_type() == TYPE); LOG_PREFIX(OMapLeafNode::make_full_merge); DEBUGT("this: {}", oc.t, *this); - return oc.tm.alloc_non_data_extent(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE) + return oc.tm.alloc_non_data_extent(oc.t, oc.hint, get_len()) .si_then([this, right] (auto &&replacement) { replacement->merge_from(*this, *right->cast()); return full_merge_ret( @@ -710,7 +710,7 @@ OMapLeafNode::make_balanced(omap_context_t oc, OMapNodeRef _right) ceph_assert(_right->get_type() == TYPE); LOG_PREFIX(OMapLeafNode::make_balanced); DEBUGT("this: {}", oc.t, *this); - return oc.tm.alloc_extents(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2) + return oc.tm.alloc_extents(oc.t, oc.hint, get_len(), 2) .si_then([this, _right] (auto &&replacement_pair) { auto replacement_left = replacement_pair.front(); auto replacement_right = replacement_pair.back(); diff --git a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h index 2267942f035..d1dd00f182f 100644 --- a/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h +++ b/src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h @@ -163,14 +163,14 @@ struct OMapLeafNode explicit OMapLeafNode(ceph::bufferptr &&ptr) : OMapNode(std::move(ptr)) { - this->set_layout_buf(this->get_bptr().c_str()); + this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length()); } // Must be identical with OMapLeafNode(ptr) after on_fully_loaded() explicit OMapLeafNode(extent_len_t length) : OMapNode(length) {} OMapLeafNode(const OMapLeafNode &rhs) : OMapNode(rhs) { - this->set_layout_buf(this->get_bptr().c_str()); + this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length()); } omap_node_meta_t get_node_meta() const final { return get_meta(); } @@ -185,7 +185,7 @@ struct OMapLeafNode uint32_t get_node_size() { return get_size(); } void on_fully_loaded() final { - this->set_layout_buf(this->get_bptr().c_str()); + this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length()); } CachedExtentRef duplicate_for_write(Transaction&) final { diff --git a/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h b/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h index 3825ebef145..db1c04ca483 100644 --- a/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h +++ b/src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h @@ -915,6 +915,7 @@ private: */ class StringKVLeafNodeLayout { char *buf = nullptr; + extent_len_t len = 0; using L = absl::container_internal::Layout; static constexpr L layout{1, 1, 1}; // = L::Partial(1, 1, 1); @@ -1014,7 +1015,7 @@ public: return get_node_key().key_off; } auto get_node_val_ptr() const { - auto tail = node->buf + OMAP_LEAF_BLOCK_SIZE; + auto tail = node->buf + node->len; if (*this == node->iter_end()) return tail; else { @@ -1029,7 +1030,7 @@ public: return (*this - 1)->get_node_val_offset(); } auto get_right_ptr_end() const { - return node->buf + OMAP_LEAF_BLOCK_SIZE - get_right_offset_end(); + return node->buf + node->len - get_right_offset_end(); } void update_offset(int offset) { @@ -1127,10 +1128,12 @@ public: StringKVLeafNodeLayout() : buf(nullptr) {} - void set_layout_buf(char *_buf) { + void set_layout_buf(char *_buf, extent_len_t _len) { + assert(_len > 0); assert(buf == nullptr); assert(_buf != nullptr); buf = _buf; + len = _len; } const_iterator iter_begin() const { @@ -1274,11 +1277,16 @@ public: } uint32_t capacity() const { - return OMAP_LEAF_BLOCK_SIZE + return len - (reinterpret_cast(layout.template Pointer<2>(buf)) - reinterpret_cast(layout.template Pointer<0>(buf))); } + auto get_len() const { + assert(len > 0); + return len; + } + bool is_overflow(size_t ksize, size_t vsize) const { return free_space() < (sizeof(omap_leaf_key_le_t) + ksize + vsize); }