Skip to content

Commit a329b00

Browse files
committed
cls/rbd: use default values for non-decoded fields in test instances
Previously, test instances for cls_rbd_snap used non-default values for the "parent" field, which is ignored during decoding. The check-generated.sh test passed because they reused the same instance for re-encoding, preserving undecoded fields. An upcoming change will allocate new instances for each encode/decode verification instead of reusing instances. This will expose discrepancies between original test instances and re-encoded values when fields contain non-default values but aren't decoded. This change sets ignored fields to their default values in test instances, ensuring consistency between encoding and decoding operations regardless of the verification approach used. Since the incompatibility of cls_rbd_snap's on-disk format was introduced in 32b14ed, which was introduced Ceph v14, we will mark this version the first incompatible version in ceph-object-corpus in the sense that the re-encoded cls_rbd_snap with v8 struct version is different from the original copy if its parent field is set with < v8 struct version. Signed-off-by: Kefu Chai <[email protected]>
1 parent 95ca3c5 commit a329b00

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/cls/rbd/cls_rbd.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,17 @@ struct cls_rbd_snap {
227227

228228
static void generate_test_instances(std::list<cls_rbd_snap*>& o) {
229229
o.push_back(new cls_rbd_snap{});
230+
// the parent field is ignored in v8 and up, so let's avoid setting it.
231+
// otherwise check-generated.sh would fail due to the disprepancies between
232+
// the original dump and re-encoded dump
230233
o.push_back(new cls_rbd_snap{1, "snap", 123456,
231-
RBD_PROTECTION_STATUS_PROTECTED,
232-
{{1, "", "image", 123}, 234}, 31, {},
234+
RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {},
233235
cls::rbd::UserSnapshotNamespace{}, 543, {}});
234236
o.push_back(new cls_rbd_snap{1, "snap", 123456,
235-
RBD_PROTECTION_STATUS_PROTECTED,
236-
{{1, "", "image", 123}, 234}, 31, {},
237+
RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {},
237238
cls::rbd::UserSnapshotNamespace{}, 543, {0}});
238239
o.push_back(new cls_rbd_snap{1, "snap", 123456,
239-
RBD_PROTECTION_STATUS_PROTECTED,
240-
{{1, "ns", "image", 123}, 234}, 31, {},
240+
RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {},
241241
cls::rbd::UserSnapshotNamespace{}, 543,
242242
{123}});
243243
}

0 commit comments

Comments
 (0)