]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: introduce omaptree_clear()
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 11 Dec 2024 02:39:15 +0000 (10:39 +0800)
committermyoungwon oh <ohmyoungwon@gmail.com>
Fri, 28 Feb 2025 14:48:28 +0000 (14:48 +0000)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
Signed-off-by: Myoungwon Oh <ohmyoungwon@gmail.com>
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h

index 42c44f6087152ebbb171aeeee0b3eef5040a511a..ba4eef8e7879c9ded683d0db83001f0813398cd4 100644 (file)
@@ -2058,43 +2058,86 @@ SeaStore::Shard::_rename(
   );
 }
 
-SeaStore::Shard::tm_ret
-SeaStore::Shard::_remove_omaps(
-  internal_context_t &ctx,
+SeaStore::base_iertr::future<omap_root_t>
+SeaStore::Shard::omaptree_do_clear(
+  Transaction& t,
   omap_root_t&& root)
 {
-  if (root.is_null()) {
-    return tm_iertr::now();
-  }
+  assert(!root.is_null());
   return seastar::do_with(
     BtreeOMapManager(*transaction_manager),
     std::move(root),
-    [&ctx](auto &omap_manager, auto &root)
+    [&t](auto &omap_manager, auto &root)
   {
-    return omap_manager.omap_clear(root, *ctx.transaction
+    return omap_manager.omap_clear(root, t
     ).si_then([&root] {
       assert(root.is_null());
+      return root;
     });
   });
 }
 
+SeaStore::base_iertr::future<>
+SeaStore::Shard::omaptree_clear_no_onode(
+  Transaction& t,
+  omap_root_t&& root)
+{
+  LOG_PREFIX(SeaStoreS::omaptree_clear_no_onode);
+  if (root.is_null()) {
+    DEBUGT("{}, null root", t, root.get_type());
+    return base_iertr::now();
+  }
+  DEBUGT("{} ...", t, root.get_type());
+  return omaptree_do_clear(t, std::move(root)
+  ).si_then([FNAME, &t](auto root) {
+    DEBUGT("{} done", t, root.get_type());
+    return base_iertr::now();
+  });
+}
+
+SeaStore::base_iertr::future<>
+SeaStore::Shard::omaptree_clear(
+  Transaction& t,
+  omap_root_t&& root,
+  Onode& onode)
+{
+  LOG_PREFIX(SeaStoreS::omaptree_clear);
+  if (root.is_null()) {
+    DEBUGT("{}, null root", t, root.get_type());
+    return base_iertr::now();
+  }
+  DEBUGT("{} ...", t, root.get_type());
+  return omaptree_do_clear(t, std::move(root)
+  ).si_then([&t, &onode, FNAME](auto root) {
+    assert(root.is_null());
+    assert(root.must_update());
+    if (root.get_type() == omap_type_t::XATTR) {
+      onode.update_xattr_root(t, root);
+    } else {
+      assert(root.get_type() == omap_type_t::OMAP);
+      onode.update_omap_root(t, root);
+    }
+    DEBUGT("{} done", t, root.get_type());
+  });
+}
+
 SeaStore::Shard::tm_ret
 SeaStore::Shard::_remove(
   internal_context_t &ctx,
   OnodeRef &onode)
 {
-  return _remove_omaps(
-    ctx,
+  return omaptree_clear_no_onode(
+    *ctx.transaction,
     onode->get_layout().omap_root.get(
       onode->get_metadata_hint(device->get_block_size()))
   ).si_then([this, &ctx, &onode] {
-    return _remove_omaps(
-      ctx,
+    return omaptree_clear_no_onode(
+      *ctx.transaction,
       onode->get_layout().xattr_root.get(
        onode->get_metadata_hint(device->get_block_size())));
   }).si_then([this, &ctx, &onode] {
-    return _remove_omaps(
-      ctx,
+    return omaptree_clear_no_onode(
+      *ctx.transaction,
       onode->get_layout().log_root.get(
        onode->get_metadata_hint(device->get_block_size())));
   }).si_then([this, &ctx, &onode] {
@@ -2338,21 +2381,10 @@ SeaStore::Shard::_omap_clear(
   ).si_then([this, &ctx, &onode] {
     auto root = onode->get_layout().omap_root.get(
       onode->get_metadata_hint(device->get_block_size()));
-    if (root.is_null()) {
-      return base_iertr::now();
-    }
-    return seastar::do_with(
-      BtreeOMapManager(*transaction_manager),
+    return omaptree_clear(
+      *ctx.transaction,
       std::move(root),
-      [&ctx, &onode](auto &omap_manager, auto &root)
-    {
-      return omap_manager.omap_clear(root, *ctx.transaction
-      ).si_then([&ctx, &onode, &root] {
-        assert(root.is_null());
-        assert(root.must_update());
-        onode->update_omap_root(*ctx.transaction, root);
-      });
-    });
+      *onode);
   });
 }
 
@@ -2575,27 +2607,14 @@ SeaStore::Shard::_rmattrs(
   internal_context_t &ctx,
   OnodeRef &onode)
 {
-  LOG_PREFIX(SeaStoreS::_rmattrs);
-  DEBUGT("onode={}", *ctx.transaction, *onode);
   onode->clear_object_info(*ctx.transaction);
   onode->clear_snapset(*ctx.transaction);
   auto root = onode->get_layout().xattr_root.get(
     onode->get_metadata_hint(device->get_block_size()));
-  if (root.is_null()) {
-    return base_iertr::now();
-  }
-  return seastar::do_with(
-    BtreeOMapManager(*transaction_manager),
+  return omaptree_clear(
+    *ctx.transaction,
     std::move(root),
-    [&ctx, &onode](auto &omap_manager, auto &root)
-  {
-    return omap_manager.omap_clear(root, *ctx.transaction
-    ).si_then([&ctx, &onode, &root] {
-      assert(root.is_null());
-      assert(root.must_update());
-      onode->update_xattr_root(*ctx.transaction, root);
-    });
-  });
+    *onode);
 }
 
 SeaStore::Shard::tm_ret
index 75a7bf7ff75d38533e5692c54c69abdee5cc93ff..2bc4f925e75cef63950654862e1e13297aec2cbf 100644 (file)
@@ -414,9 +414,6 @@ public:
       std::vector<OnodeRef> &onodes,
       ceph::os::Transaction::iterator &i);
 
-    tm_ret _remove_omaps(
-      internal_context_t &ctx,
-      omap_root_t &&omap_root);
     tm_ret _remove(
       internal_context_t &ctx,
       OnodeRef &onode);
@@ -515,6 +512,23 @@ public:
       lat.sample_sum += std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
     }
 
+    /*
+     * omaptree interfaces
+     */
+
+    base_iertr::future<omap_root_t> omaptree_do_clear(
+      Transaction& t,
+      omap_root_t&& root);
+
+    base_iertr::future<> omaptree_clear_no_onode(
+      Transaction& t,
+      omap_root_t&& root);
+
+    base_iertr::future<> omaptree_clear(
+      Transaction& t,
+      omap_root_t&& root,
+      Onode& onode);
+
   private:
     std::string root;
     Device* device;