Looks good to me. Reviewed-by: Milind Changire <mchangir@xxxxxxxxxx> On Tue, Jun 6, 2023 at 9:11 AM <xiubli@xxxxxxxxxx> wrote: > > From: Xiubo Li <xiubli@xxxxxxxxxx> > > 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. > > URL: https://tracker.ceph.com/issues/61584 > Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx> > --- > fs/ceph/dir.c | 14 +++++++------- > fs/ceph/file.c | 2 +- > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c > index 09bbd0ffbf4f..1b46f2b998c3 100644 > --- a/fs/ceph/dir.c > +++ b/fs/ceph/dir.c > @@ -925,7 +925,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, > set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); > req->r_args.mknod.mode = cpu_to_le32(mode); > req->r_args.mknod.rdev = cpu_to_le32(rdev); > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > > ceph_as_ctx_to_req(req, &as_ctx); > @@ -1037,7 +1037,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir, > set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); > req->r_dentry = dget(dentry); > req->r_num_caps = 2; > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > > ceph_as_ctx_to_req(req, &as_ctx); > @@ -1112,7 +1112,7 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, > ihold(dir); > set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); > req->r_args.mkdir.mode = cpu_to_le32(mode); > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > > ceph_as_ctx_to_req(req, &as_ctx); > @@ -1173,7 +1173,7 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, > req->r_parent = dir; > ihold(dir); > set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > /* release LINK_SHARED on source inode (mds will lock it) */ > req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; > @@ -1312,7 +1312,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) > req->r_num_caps = 2; > req->r_parent = dir; > ihold(dir); > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > req->r_inode_drop = ceph_drop_caps_for_unlink(inode); > > @@ -1418,9 +1418,9 @@ static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir, > req->r_parent = new_dir; > ihold(new_dir); > set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); > - req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED; > + req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; > req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL; > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > /* release LINK_RDCACHE on source inode (mds will lock it) */ > req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; > diff --git a/fs/ceph/file.c b/fs/ceph/file.c > index 9e74ed673f93..e878a462c7c3 100644 > --- a/fs/ceph/file.c > +++ b/fs/ceph/file.c > @@ -799,7 +799,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, > if (flags & O_CREAT) { > struct ceph_file_layout lo; > > - req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; > + req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; > req->r_dentry_unless = CEPH_CAP_FILE_EXCL; > > ceph_as_ctx_to_req(req, &as_ctx); > -- > 2.40.1 > -- Milind