From: Dhairya Parmar Date: Wed, 15 Oct 2025 11:43:27 +0000 (+0530) Subject: mds: update older versioned sr_t struct(s) to incorporate snapshot visibility flag X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f40f4cee9402be97426a2edcc37880b8b9bc0201;p=ceph.git mds: update older versioned sr_t struct(s) to incorporate snapshot visibility flag - 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 --- diff --git a/src/mds/snap.cc b/src/mds/snap.cc index 9192c956382b..5e594e2d7cab 100644 --- a/src/mds/snap.cc +++ b/src/mds/snap.cc @@ -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); }