diff mbox series

[3/3] ceph: must hold snap_rwsem when filling inode for async create

Message ID 20210603165231.110559-4-jlayton@kernel.org
State New
Headers show
Series ceph: locking fixes for snaprealm handling | expand

Commit Message

Jeff Layton June 3, 2021, 4:52 p.m. UTC
...and add a lockdep assertion for it to ceph_fill_inode().

Cc: stable@vger.kernel.org # v5.7+
Fixes: 9a8d03ca2e2c3 ("ceph: attempt to do async create when possible")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/file.c  | 3 +++
 fs/ceph/inode.c | 2 ++
 2 files changed, 5 insertions(+)

Comments

Ilya Dryomov June 21, 2021, 7:45 p.m. UTC | #1
On Thu, Jun 3, 2021 at 6:52 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> ...and add a lockdep assertion for it to ceph_fill_inode().
>
> Cc: stable@vger.kernel.org # v5.7+
> Fixes: 9a8d03ca2e2c3 ("ceph: attempt to do async create when possible")
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/file.c  | 3 +++
>  fs/ceph/inode.c | 2 ++
>  2 files changed, 5 insertions(+)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index a01ad342a91d..d3874c2df4b1 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -578,6 +578,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
>         struct ceph_inode_info *ci = ceph_inode(dir);
>         struct inode *inode;
>         struct timespec64 now;
> +       struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
>         struct ceph_vino vino = { .ino = req->r_deleg_ino,
>                                   .snap = CEPH_NOSNAP };
>
> @@ -615,8 +616,10 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
>
>         ceph_file_layout_to_legacy(lo, &in.layout);
>
> +       down_read(&mdsc->snap_rwsem);
>         ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session,
>                               req->r_fmode, NULL);
> +       up_read(&mdsc->snap_rwsem);
>         if (ret) {
>                 dout("%s failed to fill inode: %d\n", __func__, ret);
>                 ceph_dir_clear_complete(dir);
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index e1c63adb196d..df0c8a724609 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -777,6 +777,8 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
>         umode_t mode = le32_to_cpu(info->mode);
>         dev_t rdev = le32_to_cpu(info->rdev);
>
> +       lockdep_assert_held(&mdsc->snap_rwsem);
> +
>         dout("%s %p ino %llx.%llx v %llu had %llu\n", __func__,
>              inode, ceph_vinop(inode), le64_to_cpu(info->version),
>              ci->i_version);
> --
> 2.31.1
>

Reviewed-by: Ilya Dryomov <idryomov@gmail.com>

Thanks,

                Ilya
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index a01ad342a91d..d3874c2df4b1 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -578,6 +578,7 @@  static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
 	struct ceph_inode_info *ci = ceph_inode(dir);
 	struct inode *inode;
 	struct timespec64 now;
+	struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
 	struct ceph_vino vino = { .ino = req->r_deleg_ino,
 				  .snap = CEPH_NOSNAP };
 
@@ -615,8 +616,10 @@  static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
 
 	ceph_file_layout_to_legacy(lo, &in.layout);
 
+	down_read(&mdsc->snap_rwsem);
 	ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session,
 			      req->r_fmode, NULL);
+	up_read(&mdsc->snap_rwsem);
 	if (ret) {
 		dout("%s failed to fill inode: %d\n", __func__, ret);
 		ceph_dir_clear_complete(dir);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index e1c63adb196d..df0c8a724609 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -777,6 +777,8 @@  int ceph_fill_inode(struct inode *inode, struct page *locked_page,
 	umode_t mode = le32_to_cpu(info->mode);
 	dev_t rdev = le32_to_cpu(info->rdev);
 
+	lockdep_assert_held(&mdsc->snap_rwsem);
+
 	dout("%s %p ino %llx.%llx v %llu had %llu\n", __func__,
 	     inode, ceph_vinop(inode), le64_to_cpu(info->version),
 	     ci->i_version);