ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: voluntarily drop Xx caps for requests those touch parent mtime
@ 2023-06-06  3:38 xiubli
  2023-06-27 13:40 ` Milind Changire
  0 siblings, 1 reply; 2+ messages in thread
From: xiubli @ 2023-06-06  3:38 UTC (permalink / raw)
  To: idryomov, ceph-devel; +Cc: jlayton, vshankar, mchangir, Xiubo Li

From: Xiubo Li <xiubli@redhat.com>

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@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: voluntarily drop Xx caps for requests those touch parent mtime
  2023-06-06  3:38 [PATCH] ceph: voluntarily drop Xx caps for requests those touch parent mtime xiubli
@ 2023-06-27 13:40 ` Milind Changire
  0 siblings, 0 replies; 2+ messages in thread
From: Milind Changire @ 2023-06-27 13:40 UTC (permalink / raw)
  To: xiubli; +Cc: idryomov, ceph-devel, jlayton, vshankar

Looks good to me.

Reviewed-by: Milind Changire <mchangir@redhat.com>

On Tue, Jun 6, 2023 at 9:11 AM <xiubli@redhat.com> wrote:
>
> From: Xiubo Li <xiubli@redhat.com>
>
> 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@redhat.com>
> ---
>  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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-27 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06  3:38 [PATCH] ceph: voluntarily drop Xx caps for requests those touch parent mtime xiubli
2023-06-27 13:40 ` Milind Changire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).