Skip to content

Commit

Permalink
ceph: move ceph_find_inode() outside the s_mutex
Browse files Browse the repository at this point in the history
ceph_find_inode() may wait on freeing inode, using it inside the s_mutex
may cause deadlock. (the freeing inode is waiting for OSD read reply, but
dispatch thread is blocked by the s_mutex)

Signed-off-by: Yan, Zheng <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
ukernel authored and idryomov committed Oct 14, 2014
1 parent 508b32d commit 6cd3bca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,12 @@ void ceph_handle_caps(struct ceph_mds_session *session,
}
}

/* lookup ino */
inode = ceph_find_inode(sb, vino);
ci = ceph_inode(inode);
dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
vino.snap, inode);

mutex_lock(&session->s_mutex);
session->s_seq++;
dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq,
Expand All @@ -3053,11 +3059,6 @@ void ceph_handle_caps(struct ceph_mds_session *session,
if (op == CEPH_CAP_OP_IMPORT)
ceph_add_cap_releases(mdsc, session);

/* lookup ino */
inode = ceph_find_inode(sb, vino);
ci = ceph_inode(inode);
dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
vino.snap, inode);
if (!inode) {
dout(" i don't have ino %llx\n", vino.ino);

Expand Down
7 changes: 4 additions & 3 deletions fs/ceph/mds_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2944,14 +2944,15 @@ static void handle_lease(struct ceph_mds_client *mdsc,
if (dname.len != get_unaligned_le32(h+1))
goto bad;

mutex_lock(&session->s_mutex);
session->s_seq++;

/* lookup inode */
inode = ceph_find_inode(sb, vino);
dout("handle_lease %s, ino %llx %p %.*s\n",
ceph_lease_op_name(h->action), vino.ino, inode,
dname.len, dname.name);

mutex_lock(&session->s_mutex);
session->s_seq++;

if (inode == NULL) {
dout("handle_lease no inode %llx\n", vino.ino);
goto release;
Expand Down

0 comments on commit 6cd3bca

Please sign in to comment.