ceph: must hold snap_rwsem when filling inode for async create

commit 27171ae6a0fdc75571e5bf3d0961631a1e4fb765 upstream.

...and add a lockdep assertion for it to ceph_fill_inode().

Cc: stable@vger.kernel.org # v5.7+
Fixes: 9a8d03ca2e ("ceph: attempt to do async create when possible")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jeff Layton
2021-06-01 09:40:25 -04:00
committed by Sasha Levin
parent de0af2651d
commit 02c303f3b9
2 changed files with 5 additions and 0 deletions

View File

@@ -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 ceph_inode_info *ci = ceph_inode(dir);
struct inode *inode; struct inode *inode;
struct timespec64 now; struct timespec64 now;
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
struct ceph_vino vino = { .ino = req->r_deleg_ino, struct ceph_vino vino = { .ino = req->r_deleg_ino,
.snap = CEPH_NOSNAP }; .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); ceph_file_layout_to_legacy(lo, &in.layout);
down_read(&mdsc->snap_rwsem);
ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session, ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session,
req->r_fmode, NULL); req->r_fmode, NULL);
up_read(&mdsc->snap_rwsem);
if (ret) { if (ret) {
dout("%s failed to fill inode: %d\n", __func__, ret); dout("%s failed to fill inode: %d\n", __func__, ret);
ceph_dir_clear_complete(dir); ceph_dir_clear_complete(dir);

View File

@@ -762,6 +762,8 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
bool new_version = false; bool new_version = false;
bool fill_inline = false; bool fill_inline = false;
lockdep_assert_held(&mdsc->snap_rwsem);
dout("%s %p ino %llx.%llx v %llu had %llu\n", __func__, dout("%s %p ino %llx.%llx v %llu had %llu\n", __func__,
inode, ceph_vinop(inode), le64_to_cpu(info->version), inode, ceph_vinop(inode), le64_to_cpu(info->version),
ci->i_version); ci->i_version);