]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: rebuild snaprealm cache if last_modified or change_attr changed
authorDhairya Parmar <dparmar@redhat.com>
Wed, 23 Jul 2025 13:12:47 +0000 (18:42 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Mon, 29 Sep 2025 08:40:30 +0000 (14:10 +0530)
For the server side snapdir visibility changes to be transported to the
client — SnapRealm cache needs to be rebuilt otherwise the same metadata
would be sent via the send_snap_update() in C_MDS_inode_update_finish() while
setting the `ceph.dir.subvolume.snaps.visible` vxattr.

The condition used to check for the `seq` and `last_destroyed` against their
cached values but for the vxattr change, it's a rather non-feasible
heavylifting to update the `seq` which involves a set of steps to prepare the
op, commit the op, journal the changes and update snap-server/client(s) just
for a mere flag update (and updating last_destroyed anyway doesn't make sense
for this case). So, compare last_modified and change_attr with their cached
values to check if the SnapRealm cache should be rebuilt. These values are
incremented in the Server::handle_client_setvxattr while toggling the
snapshot visibility xattr and this would enforce a cache rebuild.

Fixes: https://tracker.ceph.com/issues/71740
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit b47f88732fc31027305b069e4a9dba3ebed2f080)
Resolves: https://jsw.ibm.com/browse/ISCE-1465

src/mds/SnapRealm.cc
src/mds/SnapRealm.h

index 0ed4cb8fae91f757d1dcdd24bb65f92759d4b174..8fbcb474eceb26e9090786e591bb4cdb31d97a88 100644 (file)
@@ -116,6 +116,8 @@ void SnapRealm::check_cache() const
   snapid_t seq;
   snapid_t last_created;
   snapid_t last_destroyed = mdcache->mds->snapclient->get_last_destroyed();
+  utime_t last_modified = srnode.last_modified;
+  uint64_t change_attr = srnode.change_attr;
   if (global || srnode.is_parent_global()) {
     last_created = mdcache->mds->snapclient->get_last_created();
     seq = std::max(last_created, last_destroyed);
@@ -124,14 +126,19 @@ void SnapRealm::check_cache() const
     seq = srnode.seq;
   }
   if (cached_seq >= seq &&
-      cached_last_destroyed == last_destroyed)
+      cached_last_destroyed == last_destroyed &&
+      cached_last_modified == last_modified &&
+      cached_change_attr >= change_attr) {
     return;
+  }
 
   cached_snap_context.clear();
 
   cached_seq = seq;
   cached_last_created = last_created;
   cached_last_destroyed = last_destroyed;
+  cached_last_modified = last_modified;
+  cached_change_attr = change_attr;
 
   cached_subvolume_ino = 0;
   if (parent)
@@ -148,6 +155,8 @@ void SnapRealm::check_cache() const
           << " cached_seq " << cached_seq
           << " cached_last_created " << cached_last_created
           << " cached_last_destroyed " << cached_last_destroyed
+          << " cached_last_modified " << cached_last_modified
+           << " cached_change_attr " << cached_change_attr
           << ")" << dendl;
 }
 
index 5fa8fef593fd3b86a08947e7f4bc595b525b36a6..455f5a050bd7b03ef58fe62e2c3b9b377bd48898 100644 (file)
@@ -149,6 +149,8 @@ private:
   mutable ceph::buffer::list cached_snap_trace;
   mutable ceph::buffer::list cached_snap_trace_new;
   mutable inodeno_t cached_subvolume_ino = 0;
+  mutable utime_t cached_last_modified = utime_t();
+  mutable uint64_t cached_change_attr = 0;
 };
 
 std::ostream& operator<<(std::ostream& out, const SnapRealm &realm);