]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: update older versioned sr_t struct(s) to incorporate snapshot visibility flag
authorDhairya Parmar <dparmar@redhat.com>
Wed, 15 Oct 2025 11:43:27 +0000 (17:13 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Mon, 1 Dec 2025 18:25:21 +0000 (23:55 +0530)
- If there is cluster upgrade, the older sr_t structs' flags would not have the
SNAPSHOT_VISIBILITY flag bit set which means the existing subvolumes would
report 0 instead of 1 for the vxattr ceph.dir.subvolume.snaps.visible which
although doesn't lead to any actual denial of access to subvolume snapshots
since the client config to respect snapshot visibility is set to false as
default but might come as a surprise to any cluster operator if the client
config is toggled to true to see the snapshot visibility being denied(since the
`flags` is reporting to be 0). So, change the in-memory flags while decoding
the sr_t members.
- bump up struct_v to 8 while encoding and while decoding, for all the structs older
than 8 be assigned SNAPSHOT_VISIBILITY flag in-memory accordingly.

Fixes: https://tracker.ceph.com/issues/73550
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
src/mds/snap.cc

index 9192c956382b8121e6e2a2ef64ee3e11a31ded80..5e594e2d7cab40e2f478fee2f6532ef9bba7cf17 100644 (file)
@@ -145,7 +145,7 @@ ostream& operator<<(ostream& out, const snaplink_t &l)
 
 void sr_t::encode(bufferlist& bl) const
 {
-  ENCODE_START(7, 4, bl);
+  ENCODE_START(8, 4, bl);
   encode(seq, bl);
   encode(created, bl);
   encode(last_created, bl);
@@ -184,6 +184,17 @@ void sr_t::decode(bufferlist::const_iterator& p)
     decode(last_modified, p);
     decode(change_attr, p);
   }
+  // ensure that after a cluster upgrade, snapshot visibility is enabled
+  // by default.
+  if (struct_v < 6) {
+    // struct_v < 6: `flags` member did not exist - initialize to default
+    // state i.e. with snapshot visibility enabled.
+    flags = SNAPDIR_VISIBILITY;
+  } else if (struct_v < 8) {
+    // struct_v 6-7: `flags` member exists but didn't have the snapshot
+    // visibility bit set. So, set it in-memory.
+    flags |= SNAPDIR_VISIBILITY;
+  }
   DECODE_FINISH(p);
 }