]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw_data_change can decode v1 format if gen was 0
authorCasey Bodley <cbodley@redhat.com>
Wed, 10 Feb 2021 00:04:19 +0000 (19:04 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Feb 2022 16:03:41 +0000 (11:03 -0500)
but if gen>0, require decoders to understand the v2 format. this way,
old clients can't decode entries with gen>0, so they won't be able to
serve them to other zones

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_datalog.h

index 1322c27043171a0e2dbf2e9c482d6b68a9b66325..565f530270b813eb3b14c4be0daf9bfef8d1dd0b 100644 (file)
@@ -55,7 +55,9 @@ struct rgw_data_change {
   uint64_t gen = 0;
 
   void encode(ceph::buffer::list& bl) const {
-    ENCODE_START(2, 2, bl);
+    // require decoders to recognize v2 when gen>0
+    const uint8_t compat = (gen == 0) ? 1 : 2;
+    ENCODE_START(2, compat, bl);
     auto t = std::uint8_t(entity_type);
     encode(t, bl);
     encode(key, bl);
@@ -71,10 +73,11 @@ struct rgw_data_change {
      entity_type = DataLogEntityType(t);
      decode(key, bl);
      decode(timestamp, bl);
-     if (struct_v < 2)
+     if (struct_v < 2) {
        gen = 0;
-     else
+     } else {
        decode(gen, bl);
+     }
      DECODE_FINISH(bl);
   }