Skip to content

Commit 15b51bd

Browse files
ukernelidryomov
authored andcommitted
ceph: stop on-going cached readdir if mds revokes FILE_SHARED cap
If directory's FILE_SHARED cap get revoked, dentry in the directory can get spliced into other directory (Eg, other client move the dentry into directory B, then we do readdir on directory B). So we should stop on-going cached readdir. this can be achieved by marking dir not complete, because __dcache_readdir() checks dir completeness before emitting each dentry. Signed-off-by: "Yan, Zheng" <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent f275635 commit 15b51bd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/ceph/caps.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,14 @@ static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap,
490490
}
491491

492492
/*
493-
* if we are newly issued FILE_SHARED, mark dir not complete; we
494-
* don't know what happened to this directory while we didn't
495-
* have the cap.
493+
* If FILE_SHARED is newly issued, mark dir not complete. We don't
494+
* know what happened to this directory while we didn't have the cap.
495+
* If FILE_SHARED is being revoked, also mark dir not complete. It
496+
* stops on-going cached readdir.
496497
*/
497-
if ((issued & CEPH_CAP_FILE_SHARED) &&
498-
(had & CEPH_CAP_FILE_SHARED) == 0) {
499-
ci->i_shared_gen++;
498+
if ((issued & CEPH_CAP_FILE_SHARED) != (had & CEPH_CAP_FILE_SHARED)) {
499+
if (issued & CEPH_CAP_FILE_SHARED)
500+
ci->i_shared_gen++;
500501
if (S_ISDIR(ci->vfs_inode.i_mode)) {
501502
dout(" marking %p NOT complete\n", &ci->vfs_inode);
502503
__ceph_dir_clear_complete(ci);

0 commit comments

Comments
 (0)