]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: perform a inplace-partial-overwrite on the corresponding block...
authorMyoungwon Oh <myoungwon.oh@samsung.com>
Thu, 16 Nov 2023 05:39:38 +0000 (14:39 +0900)
committerMyoungwon Oh <myoungwon.oh@samsung.com>
Thu, 28 Dec 2023 02:55:11 +0000 (11:55 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/object_data_handler.h
src/crimson/os/seastore/transaction.h
src/test/crimson/seastore/test_block.h

index 4d1dc929607d0859f6441219a70332bd383f3904..f0c7a0a34f24214ba3c5b8917f694e80d641dbf0 100644 (file)
@@ -1261,6 +1261,24 @@ record_t Cache::prepare_record(
     }
   }
 
+  for (auto &i: t.written_inplace_ool_block_list) {
+    if (!i->is_valid()) {
+      continue;
+    }
+    assert(i->state == CachedExtent::extent_state_t::DIRTY);
+    assert(i->version > 0);
+    remove_from_dirty(i);
+    // set the version to zero because the extent state is now clean
+    // in order to handle this transparently
+    i->version = 0;
+    i->dirty_from_or_retired_at = JOURNAL_SEQ_MIN;
+    i->state = CachedExtent::extent_state_t::CLEAN;
+    assert(i->is_logical());
+    i->cast<LogicalCachedExtent>()->clear_delta();
+    touch_extent(*i);
+    DEBUGT("inplace rewrite ool block is commmitted -- {}", t, *i);
+  }
+
   for (auto &i: t.existing_block_list) {
     if (i->is_valid()) {
       alloc_delta.alloc_blk_ranges.emplace_back(
@@ -1330,7 +1348,8 @@ record_t Cache::prepare_record(
              t.num_allocated_invalid_extents);
 
   auto& ool_stats = t.get_ool_write_stats();
-  ceph_assert(ool_stats.extents.num == t.written_ool_block_list.size());
+  ceph_assert(ool_stats.extents.num == t.written_ool_block_list.size() +
+    t.written_inplace_ool_block_list.size());
 
   if (record.is_empty()) {
     SUBINFOT(seastore_t,
index 8bd4a269385118d6410b9c15481cf96aafd5ea9e..18c102ed3e17398a8712de2ac50f4250db058039 100644 (file)
@@ -1242,6 +1242,8 @@ public:
 
   void on_replace_prior(Transaction &t) final;
 
+  virtual void clear_delta() {}
+
   virtual ~LogicalCachedExtent();
 protected:
 
index b7aabefc644148c9fc0e4e7d0e3d458f55067683..f53b9f5be9163c301da30732c7aa9c7ba7857fbf 100644 (file)
@@ -799,7 +799,14 @@ RandomBlockOolWriter::do_write(
     ).safe_then([&t, &ex, paddr, FNAME]() {
       TRACET("ool extent written at {} -- {}",
             t, paddr, *ex);
-      t.mark_allocated_extent_ool(ex);
+      if (ex->is_initial_pending()) {
+       t.mark_allocated_extent_ool(ex);
+      } else if (ex->is_dirty()) {
+       assert(t.get_src() == transaction_type_t::TRIM_DIRTY);
+       t.mark_inplace_rewrite_extent_ool(ex);
+      } else {
+       ceph_assert("impossible");
+      }
       return alloc_write_iertr::now();
     });
   });
index eaa05da8d545675b7e8a552ee3034e1a9fbcfb43..76d69eb73f9b1169b1f57e2ef553bf5703ccf828 100644 (file)
@@ -60,6 +60,10 @@ struct ObjectDataBlock : crimson::os::seastore::LogicalCachedExtent {
   ceph::bufferlist get_delta() final;
 
   void apply_delta(const ceph::bufferlist &bl) final;
+
+  void clear_delta() final {
+    delta.clear();
+  }
 };
 using ObjectDataBlockRef = TCachedExtentRef<ObjectDataBlock>;
 
index b43fb0d9cd8ee642b9574e66c2f757bd9dca787d..a283982f699e19116be8cc0444dafbb98e2ffa85 100644 (file)
@@ -217,6 +217,12 @@ public:
     written_ool_block_list.push_back(ref);
   }
 
+  void mark_inplace_rewrite_extent_ool(LogicalCachedExtentRef& ref) {
+    assert(ref->get_paddr().is_absolute());
+    assert(!ref->is_inline());
+    written_inplace_ool_block_list.push_back(ref);
+  }
+
   void add_inplace_rewrite_extent(CachedExtentRef ref) {
    ceph_assert(!is_weak());
    ceph_assert(ref);
@@ -400,6 +406,7 @@ public:
     delayed_alloc_list.clear();
     inline_block_list.clear();
     written_ool_block_list.clear();
+    written_inplace_ool_block_list.clear();
     pre_alloc_list.clear();
     pre_inplace_rewrite_list.clear();
     retired_set.clear();
@@ -555,6 +562,8 @@ private:
   std::list<CachedExtentRef> inline_block_list;
   /// fresh blocks that will be committed with out-of-line record
   std::list<CachedExtentRef> written_ool_block_list;
+  /// dirty blocks that will be committed out-of-line with inplace rewrite
+  std::list<LogicalCachedExtentRef> written_inplace_ool_block_list;
 
   /// list of mutated blocks, holds refcounts, subset of write_set
   std::list<CachedExtentRef> mutated_block_list;
index ccdafb7843fecd0b7f79d98947e551ea3f2623c2..bfb50670420cb54054336b8c78bb59e0948ce8ad 100644 (file)
@@ -79,6 +79,10 @@ struct TestBlock : crimson::os::seastore::LogicalCachedExtent {
   }
 
   void apply_delta(const ceph::bufferlist &bl) final;
+
+  void clear_delta() final {
+    delta.clear();
+  }
 };
 using TestBlockRef = TCachedExtentRef<TestBlock>;