]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: use default values for non-decoded fields in test instances 64102/head
authorKefu Chai <tchaikov@gmail.com>
Sat, 14 Jun 2025 13:44:05 +0000 (21:44 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 23 Jun 2025 07:49:05 +0000 (09:49 +0200)
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 <tchaikov@gmail.com>
(cherry picked from commit a329b00579546ad2c069d792bde34cd44cfa0b43)

src/cls/rbd/cls_rbd.h

index f0cadf8ae5525d410d775e795315008d42aa315c..9d9bf326490679391e556e18f7ecd9b0d4128244 100644 (file)
@@ -227,17 +227,17 @@ struct cls_rbd_snap {
 
   static void generate_test_instances(std::list<cls_rbd_snap*>& 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}});
   }