Skip to content

Commit 2426c11

Browse files
committed
os/bluestore: use default value for non-decoded field in test instances
The sbid field added in commit a7f8e23 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 <[email protected]>
1 parent a668040 commit 2426c11

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/os/bluestore/bluestore_types.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,16 @@ void bluestore_shared_blob_t::dump(Formatter *f) const
13611361
void bluestore_shared_blob_t::generate_test_instances(
13621362
list<bluestore_shared_blob_t*>& ls)
13631363
{
1364-
ls.push_back(new bluestore_shared_blob_t(1));
1364+
std::list<bluestore_extent_ref_map_t*> extent_ref_maps;
1365+
bluestore_extent_ref_map_t::generate_test_instances(extent_ref_maps);
1366+
// use 0 for sbid, as this field is not persited, and is always set during
1367+
// instance construction, so including a non-default value in dumps would
1368+
// cause ceph-dencoder verification failures when comparing original and
1369+
// re-encoded value.
1370+
ls.push_back(new bluestore_shared_blob_t{0, std::move(*extent_ref_maps.front())});
1371+
for (auto* m : extent_ref_maps) {
1372+
delete m;
1373+
}
13651374
}
13661375

13671376
ostream& operator<<(ostream& out, const bluestore_shared_blob_t& sb)

0 commit comments

Comments
 (0)