From: Kefu Chai Date: Sun, 15 Jun 2025 05:40:10 +0000 (+0800) Subject: os/bluestore: use default value for non-decoded field in test instances X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2426c112ae02b2ffd05016ba76bb6513efec2c92;p=ceph.git os/bluestore: use default value for non-decoded field in test instances 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 --- diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 7673b73dc1cf..4739a7f3687c 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -1361,7 +1361,16 @@ void bluestore_shared_blob_t::dump(Formatter *f) const void bluestore_shared_blob_t::generate_test_instances( list& ls) { - ls.push_back(new bluestore_shared_blob_t(1)); + std::list 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)