Skip to content

Commit 7fb744f

Browse files
committed
mds: rebuild snaprealm cache if last_modified or change_attr changed
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 <[email protected]>
1 parent b855099 commit 7fb744f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/mds/SnapRealm.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void SnapRealm::check_cache() const
117117
snapid_t seq;
118118
snapid_t last_created;
119119
snapid_t last_destroyed = mdcache->mds->snapclient->get_last_destroyed();
120+
utime_t last_modified = srnode.last_modified;
121+
uint64_t change_attr = srnode.change_attr;
120122
if (global || srnode.is_parent_global()) {
121123
last_created = mdcache->mds->snapclient->get_last_created();
122124
seq = std::max(last_created, last_destroyed);
@@ -125,14 +127,19 @@ void SnapRealm::check_cache() const
125127
seq = srnode.seq;
126128
}
127129
if (cached_seq >= seq &&
128-
cached_last_destroyed == last_destroyed)
130+
cached_last_destroyed == last_destroyed &&
131+
cached_last_modified == last_modified &&
132+
cached_change_attr >= change_attr) {
129133
return;
134+
}
130135

131136
cached_snap_context.clear();
132137

133138
cached_seq = seq;
134139
cached_last_created = last_created;
135140
cached_last_destroyed = last_destroyed;
141+
cached_last_modified = last_modified;
142+
cached_change_attr = change_attr;
136143

137144
cached_subvolume_ino = 0;
138145
if (parent)
@@ -149,6 +156,8 @@ void SnapRealm::check_cache() const
149156
<< " cached_seq " << cached_seq
150157
<< " cached_last_created " << cached_last_created
151158
<< " cached_last_destroyed " << cached_last_destroyed
159+
<< " cached_last_modified " << cached_last_modified
160+
<< " cached_change_attr " << cached_change_attr
152161
<< ")" << dendl;
153162
}
154163

src/mds/SnapRealm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ struct SnapRealm {
151151
mutable ceph::buffer::list cached_snap_trace;
152152
mutable ceph::buffer::list cached_snap_trace_new;
153153
mutable inodeno_t cached_subvolume_ino = 0;
154+
mutable utime_t cached_last_modified = utime_t();
155+
mutable uint64_t cached_change_attr = 0;
154156
};
155157

156158
std::ostream& operator<<(std::ostream& out, const SnapRealm &realm);

0 commit comments

Comments
 (0)