]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/epm: RandomBlockOolWriter to update extents upon submitting writes
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 19 Jul 2024 08:26:12 +0000 (16:26 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 6 Aug 2024 03:05:57 +0000 (11:05 +0800)
In order to move the ool write futures out of the collection lock, which
will be after the transaction prepare phase.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/extent_placement_manager.h

index f4d2c021333db710e8cf2e2910847e508d0b3d67..1ac7c68484b1761ea02798fc58575202213e5df5 100644 (file)
@@ -1008,13 +1008,15 @@ RandomBlockOolWriter::do_write(
   assert(!extents.empty());
   DEBUGT("start with {} allocated extents",
          t, extents.size());
-  return trans_intr::do_for_each(extents,
-    [this, &t, FNAME](auto& ex) {
+  std::vector<write_info_t> writes;
+  writes.reserve(extents.size());
+  for (auto& ex : extents) {
     auto paddr = ex->get_paddr();
     assert(paddr.is_absolute());
     RandomBlockManager * rbm = rb_cleaner->get_rbm(paddr); 
     assert(rbm);
-    TRACE("extent {}, allocated addr {}", fmt::ptr(ex.get()), paddr);
+    TRACE("write extent {}, paddr {} ...",
+          fmt::ptr(ex.get()), paddr);
     auto& stats = t.get_ool_write_stats();
     stats.extents.num += 1;
     stats.extents.bytes += ex->get_length();
@@ -1038,29 +1040,33 @@ RandomBlockOolWriter::do_write(
       trans_stats.data_bytes += ex->get_length();
       w_stats.data_bytes += ex->get_length();
     }
-    return trans_intr::make_interruptible(
-      rbm->write(paddr + offset,
-       bp
-      ).handle_error(
-       alloc_write_ertr::pass_further{},
-       crimson::ct_error::assert_all{
-         "Invalid error when writing record"}
-      )
-    ).si_then([this, &t, &ex, paddr, FNAME] {
-      TRACET("ool extent written at {} -- {}",
-            t, paddr, *ex);
-      if (ex->is_initial_pending()) {
-       t.mark_allocated_extent_ool(ex);
-      } else if (can_inplace_rewrite(t, ex)) {
-        assert(ex->is_logical());
-       t.mark_inplace_rewrite_extent_ool(
-          ex->template cast<LogicalCachedExtent>());
-      } else {
-       ceph_assert("impossible");
-      }
-      return alloc_write_iertr::now();
-    });
-  });
+    writes.push_back(write_info_t{paddr + offset, std::move(bp), rbm});
+
+    if (ex->is_initial_pending()) {
+      t.mark_allocated_extent_ool(ex);
+    } else if (can_inplace_rewrite(t, ex)) {
+      assert(ex->is_logical());
+      t.mark_inplace_rewrite_extent_ool(
+        ex->template cast<LogicalCachedExtent>());
+    } else {
+      ceph_assert("impossible");
+    }
+  }
+
+  return trans_intr::make_interruptible(
+    seastar::do_with(std::move(writes),
+      [](auto& writes) {
+      return crimson::do_for_each(writes,
+        [](auto& info) {
+        return info.rbm->write(info.offset, info.bp
+        ).handle_error(
+          alloc_write_ertr::pass_further{},
+          crimson::ct_error::assert_all{
+            "Invalid error when writing record"}
+        );
+      });
+    })
+  );
 }
 
 }
index 8c51d587586ec1bf4c22d4f2a21e5afd0b6a52df..7c4110c053ef5060d1860c73e4ae4198997928e0 100644 (file)
@@ -190,6 +190,11 @@ public:
   }
 #endif
 private:
+  struct write_info_t {
+    paddr_t offset;
+    ceph::bufferptr bp;
+    RandomBlockManager* rbm;
+  };
   alloc_write_iertr::future<> do_write(
     Transaction& t,
     std::list<CachedExtentRef> &extent);