Skip to content

Commit 27171ae

Browse files
jtlaytonidryomov
authored andcommitted
ceph: must hold snap_rwsem when filling inode for async create
...and add a lockdep assertion for it to ceph_fill_inode(). Cc: [email protected] # v5.7+ Fixes: 9a8d03c ("ceph: attempt to do async create when possible") Signed-off-by: Jeff Layton <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 13311e7 commit 27171ae

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

fs/ceph/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
578578
struct ceph_inode_info *ci = ceph_inode(dir);
579579
struct inode *inode;
580580
struct timespec64 now;
581+
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
581582
struct ceph_vino vino = { .ino = req->r_deleg_ino,
582583
.snap = CEPH_NOSNAP };
583584

@@ -615,8 +616,10 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
615616

616617
ceph_file_layout_to_legacy(lo, &in.layout);
617618

619+
down_read(&mdsc->snap_rwsem);
618620
ret = ceph_fill_inode(inode, NULL, &iinfo, NULL, req->r_session,
619621
req->r_fmode, NULL);
622+
up_read(&mdsc->snap_rwsem);
620623
if (ret) {
621624
dout("%s failed to fill inode: %d\n", __func__, ret);
622625
ceph_dir_clear_complete(dir);

fs/ceph/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
777777
umode_t mode = le32_to_cpu(info->mode);
778778
dev_t rdev = le32_to_cpu(info->rdev);
779779

780+
lockdep_assert_held(&mdsc->snap_rwsem);
781+
780782
dout("%s %p ino %llx.%llx v %llu had %llu\n", __func__,
781783
inode, ceph_vinop(inode), le64_to_cpu(info->version),
782784
ci->i_version);

0 commit comments

Comments
 (0)