]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/epm: introduce RandomBlockOolWriter
authormyoungwon oh <ohmyoungwon@gmail.com>
Mon, 5 Sep 2022 05:12:17 +0000 (14:12 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Wed, 16 Nov 2022 09:15:24 +0000 (18:15 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/extent_placement_manager.h
src/crimson/os/seastore/transaction.h

index 500a2bed66a7d509ead5fa0d1ae41029136a32b2..25e29988d723d2d315c9d13ea6adc75cec55264e 100644 (file)
@@ -494,4 +494,53 @@ void ExtentPlacementManager::BackgroundProcess::register_metrics()
   });
 }
 
+RandomBlockOolWriter::alloc_write_iertr::future<>
+RandomBlockOolWriter::alloc_write_ool_extents(
+  Transaction& t,
+  std::list<LogicalCachedExtentRef>& extents)
+{
+  if (extents.empty()) {
+    return alloc_write_iertr::now();
+  }
+  return seastar::with_gate(write_guard, [this, &t, &extents] {
+    return do_write(t, extents);
+  });
+}
+
+RandomBlockOolWriter::alloc_write_iertr::future<>
+RandomBlockOolWriter::do_write(
+  Transaction& t,
+  std::list<LogicalCachedExtentRef>& extents)
+{
+  LOG_PREFIX(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) {
+    auto paddr = ex->get_paddr();
+    assert(paddr.is_absolute());
+    RandomBlockManager * rbm = rb_cleaner->get_rbm(paddr); 
+    assert(rbm);
+    TRACE("extent {}, allocated addr {}", ex, paddr);
+    auto& stats = t.get_ool_write_stats();
+    stats.extents.num += 1;
+    stats.extents.bytes += ex->get_length();
+    stats.num_records += 1;
+
+    return rbm->write(paddr,
+      ex->get_bptr()
+    ).handle_error(
+      alloc_write_iertr::pass_further{},
+      crimson::ct_error::assert_all{
+       "Invalid error when writing record"}
+    ).safe_then([&t, &ex, paddr, FNAME]() {
+      TRACET("ool extent written at {} -- {}",
+            t, paddr, *ex);
+      t.mark_extent_ool(ex, paddr);
+      return alloc_write_iertr::now();
+    });
+  });
+}
+
 }
index 061aa54a6a8085731d4d028ab8cdc13112211700..cb0dde5b0c0bedf967b3c6df89d2c52f87b64499 100644 (file)
@@ -85,6 +85,36 @@ private:
   seastar::gate write_guard;
 };
 
+
+class RandomBlockOolWriter : public ExtentOolWriter {
+public:
+  RandomBlockOolWriter(RBMCleaner* rb_cleaner) :
+    rb_cleaner(rb_cleaner) {}
+
+  using open_ertr = ExtentOolWriter::open_ertr;
+  open_ertr::future<> open() final {
+    return open_ertr::now();
+  }
+
+  alloc_write_iertr::future<> alloc_write_ool_extents(
+    Transaction &t,
+    std::list<LogicalCachedExtentRef> &extents) final;
+
+  close_ertr::future<> close() final {
+    return write_guard.close().then([this] {
+      write_guard = seastar::gate();
+      return close_ertr::now();
+    });
+  }
+private:
+  alloc_write_iertr::future<> do_write(
+    Transaction& t,
+    std::list<LogicalCachedExtentRef> &extent);
+
+  RBMCleaner* rb_cleaner;
+  seastar::gate write_guard;
+};
+
 class ExtentPlacementManager {
 public:
   ExtentPlacementManager() {
index 0f5f31f277d7c4601fda20e7fd39a1de489d8a59..d89feb2b390f3a3b1246687e35bf3bcdc8e1d0b9 100644 (file)
@@ -190,6 +190,10 @@ public:
     write_set.insert(*ref);
   }
 
+  void mark_extent_ool(LogicalCachedExtentRef& ref, paddr_t final_addr) {
+    mark_delayed_extent_ool(ref, final_addr);
+  }
+
   void add_mutated_extent(CachedExtentRef ref) {
     ceph_assert(!is_weak());
     assert(ref->is_exist_mutation_pending() ||