From 632f30a2f995354ca5b94a34215a2b22bc74d2da Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 14 Jun 2025 21:44:05 +0800 Subject: [PATCH] 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 32b14ed1, 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 (cherry picked from commit a329b00579546ad2c069d792bde34cd44cfa0b43) --- src/cls/rbd/cls_rbd.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cls/rbd/cls_rbd.h b/src/cls/rbd/cls_rbd.h index f0cadf8ae5525..9d9bf32649067 100644 --- a/src/cls/rbd/cls_rbd.h +++ b/src/cls/rbd/cls_rbd.h @@ -227,17 +227,17 @@ struct cls_rbd_snap { static void generate_test_instances(std::list& o) { o.push_back(new cls_rbd_snap{}); + // the parent field is ignored in v8 and up, so let's avoid setting it. + // otherwise check-generated.sh would fail due to the disprepancies between + // the original dump and re-encoded dump o.push_back(new cls_rbd_snap{1, "snap", 123456, - RBD_PROTECTION_STATUS_PROTECTED, - {{1, "", "image", 123}, 234}, 31, {}, + RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {}, cls::rbd::UserSnapshotNamespace{}, 543, {}}); o.push_back(new cls_rbd_snap{1, "snap", 123456, - RBD_PROTECTION_STATUS_PROTECTED, - {{1, "", "image", 123}, 234}, 31, {}, + RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {}, cls::rbd::UserSnapshotNamespace{}, 543, {0}}); o.push_back(new cls_rbd_snap{1, "snap", 123456, - RBD_PROTECTION_STATUS_PROTECTED, - {{1, "ns", "image", 123}, 234}, 31, {}, + RBD_PROTECTION_STATUS_PROTECTED, {}, 31, {}, cls::rbd::UserSnapshotNamespace{}, 543, {123}}); } -- 2.39.5