]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: assert the committing delta is not empty
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 15 Jul 2021 02:17:38 +0000 (10:17 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 20 Jul 2021 08:19:44 +0000 (16:19 +0800)
It makes no sense to commit an empty delta. It is mostly an issue that
user forget to generate delta during mutation, or there are futile
copy-on-write operations.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/onode_manager/staged-fltree/node_delta_recorder.h
src/test/crimson/seastore/test_block.cc
src/test/crimson/seastore/test_block.h

index 10c38d066f584da9e140429007a6585e41d25fb1..e1727e0aac90767609790b57ad14bf0df6e7964f 100644 (file)
@@ -573,6 +573,7 @@ record_t Cache::prepare_record(Transaction &t)
        });
       i->last_committed_crc = final_crc;
     }
+    assert(record.deltas.back().bl.length());
   }
 
   // Transaction is now a go, set up in-memory cache state
index 27df8e23a19b3b655c3682e08d247c0aa86c93ad..ea26195de71caacf8474cfa51242c2968d5067eb 100644 (file)
@@ -29,7 +29,6 @@ class DeltaRecorder {
   }
 
   ceph::bufferlist get_delta() {
-    assert(!is_empty());
     return std::move(encoded);
   }
 
index f3d6531bd92d93825adb39caa838333f97cc4a62..f7a39b0ef59cc25e90d782b9c7d6170441f84c14 100644 (file)
@@ -22,4 +22,20 @@ void TestBlock::apply_delta(const ceph::bufferlist &bl) {
   }
 }
 
+ceph::bufferlist TestBlockPhysical::get_delta() {
+  ceph::bufferlist bl;
+  encode(delta, bl);
+  return bl;
+}
+
+void TestBlockPhysical::apply_delta_and_adjust_crc(
+    paddr_t, const ceph::bufferlist &bl) {
+  auto biter = bl.begin();
+  decltype(delta) deltas;
+  decode(deltas, biter);
+  for (auto &&d : deltas) {
+    set_contents(d.val, d.offset, d.len);
+  }
+}
+
 }
index 44ec65a2375161a2fc7518b617bdb1c36a088fc7..4df99784ad40d3d31b2c494139bb05b7dced0ef8 100644 (file)
@@ -90,7 +90,7 @@ struct TestBlockPhysical : crimson::os::seastore::CachedExtent{
 
   TestBlockPhysical(ceph::bufferptr &&ptr)
     : CachedExtent(std::move(ptr)) {}
-  TestBlockPhysical(const TestBlock &other)
+  TestBlockPhysical(const TestBlockPhysical &other)
     : CachedExtent(other) {}
 
   CachedExtentRef duplicate_for_write() final {
@@ -104,15 +104,16 @@ struct TestBlockPhysical : crimson::os::seastore::CachedExtent{
 
   void set_contents(char c, uint16_t offset, uint16_t len) {
     ::memset(get_bptr().c_str() + offset, c, len);
+    delta.push_back({c, offset, len});
   }
 
   void set_contents(char c) {
     set_contents(c, 0, get_length());
   }
 
-  ceph::bufferlist get_delta() final { return ceph::bufferlist(); }
+  ceph::bufferlist get_delta() final;
 
-  void apply_delta_and_adjust_crc(paddr_t, const ceph::bufferlist &bl) final {}
+  void apply_delta_and_adjust_crc(paddr_t, const ceph::bufferlist &bl) final;
 };
 using TestBlockPhysicalRef = TCachedExtentRef<TestBlockPhysical>;