]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use default value for non-decoded field in test instances 63935/head
authorKefu Chai <tchaikov@gmail.com>
Sun, 15 Jun 2025 05:40:10 +0000 (13:40 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 23 Jun 2025 14:02:42 +0000 (22:02 +0800)
The sbid field added in commit a7f8e231 is set during construction
but not persisted to disk. Including it in dump() output causes
discrepancies between original and re-encoded instances, leading
to test failures in readable.sh and check-generated.sh.

Current tests pass because they reuse the same instance for
re-encoding, preserving non-persisted fields. An upcoming change
will allocate fresh instances for each decode operation, which
will expose this issue and break tests.

Use default value for sbid when generating test instances to ensure
consistency between encoding and decoding operations.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/os/bluestore/bluestore_types.cc

index 7673b73dc1cfb33cf9897e6cebe40773e7fd5e30..4739a7f3687c164617afdee21247d3c4378c7751 100644 (file)
@@ -1361,7 +1361,16 @@ void bluestore_shared_blob_t::dump(Formatter *f) const
 void bluestore_shared_blob_t::generate_test_instances(
   list<bluestore_shared_blob_t*>& ls)
 {
-  ls.push_back(new bluestore_shared_blob_t(1));
+  std::list<bluestore_extent_ref_map_t*> extent_ref_maps;
+  bluestore_extent_ref_map_t::generate_test_instances(extent_ref_maps);
+  // use 0 for sbid, as this field is not persited, and is always set during
+  // instance construction, so including a non-default value in dumps would
+  // cause ceph-dencoder verification failures when comparing original and
+  // re-encoded value.
+  ls.push_back(new bluestore_shared_blob_t{0, std::move(*extent_ref_maps.front())});
+  for (auto* m : extent_ref_maps) {
+    delete m;
+  }
 }
 
 ostream& operator<<(ostream& out, const bluestore_shared_blob_t& sb)