]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: allocate OMapLeafNode depending on the type
authorMyoungwon Oh <ohmyoungwon@gmail.com>
Mon, 25 Nov 2024 09:58:07 +0000 (09:58 +0000)
committermyoungwon oh <ohmyoungwon@gmail.com>
Thu, 20 Feb 2025 12:27:47 +0000 (12:27 +0000)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/omap_manager.h
src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc
src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h
src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc
src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h
src/crimson/os/seastore/omap_manager/btree/string_kv_node_layout.h

index e398b18d1fc30caa5c347b9ead25cf1b56f2bced..e017f8d7be2d071d3ba00afea5d9f3b21cc3f8d1 100644 (file)
@@ -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 {
 
index 1e4afffaf7bcd64e0c30c5616741e6cf2d16e86f..6b5a452ab920299b7782cc4bec9e41958a2fbd4d 100644 (file)
@@ -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<OMapLeafNode>(t, hint, OMAP_LEAF_BLOCK_SIZE)
+  return tm.alloc_non_data_extent<OMapLeafNode>(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};
index db6ba5ea531208b95c14d09afde55f85fb8e6270..5f70d565c1e58e9db899218bb015ae888d93a26e 100644 (file)
@@ -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<BtreeOMapManager>;
 
index df97f394a0d12ba6ffdcc123b2403ca5a1420b15..5ba964ee99a5219264e7dfe489df3c3872cf0e26 100644 (file)
@@ -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<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2)
+  return oc.tm.alloc_extents<OMapLeafNode>(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<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE)
+  return oc.tm.alloc_non_data_extent<OMapLeafNode>(oc.t, oc.hint, get_len())
     .si_then([this, right] (auto &&replacement) {
       replacement->merge_from(*this, *right->cast<OMapLeafNode>());
       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<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2)
+  return oc.tm.alloc_extents<OMapLeafNode>(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();
index 2267942f0355a20ead9528c5446af50a27bcf238..d1dd00f182f474065fb2ff7216b65308f11dc2e5 100644 (file)
@@ -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 {
index 3825ebef145534fd62eae7052f49ef679af1b4f9..db1c04ca4835ea0cdd1f2261e457ab64828a53ed 100644 (file)
@@ -915,6 +915,7 @@ private:
  */
 class StringKVLeafNodeLayout {
   char *buf = nullptr;
+  extent_len_t len = 0;
 
   using L = absl::container_internal::Layout<ceph_le32, omap_node_meta_le_t, omap_leaf_key_le_t>;
   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<char*>(layout.template Pointer<2>(buf))
       - reinterpret_cast<char*>(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);
   }