Skip to content

Commit d9d00f7

Browse files
lxbszidryomov
authored andcommitted
ceph: voluntarily drop Xx caps for requests those touch parent mtime
For write requests the parent's mtime will be updated correspondingly. And if the 'Xx' caps is issued and when releasing other caps together with the write requests the MDS Locker will try to eval the xattr lock, which need to change the locker state excl --> sync and need to do Xx caps revocation. Just voluntarily dropping CEPH_CAP_XATTR_EXCL caps to avoid a cap revoke message, which could cause the mtime will be overwrote by stale one. [ idryomov: break unnecessarily long lines ] Link: https://tracker.ceph.com/issues/61584 Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Milind Changire <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 8b0da5c commit d9d00f7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fs/ceph/dir.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir,
886886
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
887887
req->r_args.mknod.mode = cpu_to_le32(mode);
888888
req->r_args.mknod.rdev = cpu_to_le32(rdev);
889-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
889+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL |
890+
CEPH_CAP_XATTR_EXCL;
890891
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
891892
if (as_ctx.pagelist) {
892893
req->r_pagelist = as_ctx.pagelist;
@@ -953,7 +954,8 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir,
953954
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
954955
req->r_dentry = dget(dentry);
955956
req->r_num_caps = 2;
956-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
957+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL |
958+
CEPH_CAP_XATTR_EXCL;
957959
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
958960
if (as_ctx.pagelist) {
959961
req->r_pagelist = as_ctx.pagelist;
@@ -1022,7 +1024,8 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir,
10221024
ihold(dir);
10231025
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
10241026
req->r_args.mkdir.mode = cpu_to_le32(mode);
1025-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
1027+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL |
1028+
CEPH_CAP_XATTR_EXCL;
10261029
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
10271030
if (as_ctx.pagelist) {
10281031
req->r_pagelist = as_ctx.pagelist;
@@ -1079,7 +1082,7 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
10791082
req->r_parent = dir;
10801083
ihold(dir);
10811084
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
1082-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
1085+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL;
10831086
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
10841087
/* release LINK_SHARED on source inode (mds will lock it) */
10851088
req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
@@ -1218,7 +1221,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
12181221
req->r_num_caps = 2;
12191222
req->r_parent = dir;
12201223
ihold(dir);
1221-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
1224+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL;
12221225
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
12231226
req->r_inode_drop = ceph_drop_caps_for_unlink(inode);
12241227

@@ -1320,9 +1323,9 @@ static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir,
13201323
req->r_parent = new_dir;
13211324
ihold(new_dir);
13221325
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
1323-
req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED;
1326+
req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL;
13241327
req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL;
1325-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
1328+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL;
13261329
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
13271330
/* release LINK_RDCACHE on source inode (mds will lock it) */
13281331
req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;

fs/ceph/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
791791
if (flags & O_CREAT) {
792792
struct ceph_file_layout lo;
793793

794-
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
794+
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL |
795+
CEPH_CAP_XATTR_EXCL;
795796
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
796797
if (as_ctx.pagelist) {
797798
req->r_pagelist = as_ctx.pagelist;

0 commit comments

Comments
 (0)