Skip to content

Commit 0444d76

Browse files
dgchinnertorvalds
authored andcommitted
fs: don't use igrab() while holding i_lock
Fix the incorrect use of igrab() inside the i_lock in NFS and Ceph‥ If we are already holding the i_lock, we have a reference to the inode so we can safely use ihold() to gain an extra reference. This avoids hangs due to lock recursion on the i_lock now that the inode_lock is gone and igrab() uses the i_lock itself. Signed-off-by: Dave Chinner <dchinner@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org Cc: Ryan Mallon <ryan@bluewatersys.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cb1817b commit 0444d76

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎fs/ceph/addr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int ceph_set_page_dirty(struct page *page)
9292
ci->i_head_snapc = ceph_get_snap_context(snapc);
9393
++ci->i_wrbuffer_ref_head;
9494
if (ci->i_wrbuffer_ref == 0)
95-
igrab(inode);
95+
ihold(inode);
9696
++ci->i_wrbuffer_ref;
9797
dout("%p set_page_dirty %p idx %lu head %d/%d -> %d/%d "
9898
"snapc %p seq %lld (%d snaps)\n",

‎fs/ceph/snap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ void ceph_queue_cap_snap(struct ceph_inode_info *ci)
463463

464464
dout("queue_cap_snap %p cap_snap %p queuing under %p\n", inode,
465465
capsnap, snapc);
466-
igrab(inode);
467-
466+
ihold(inode);
467+
468468
atomic_set(&capsnap->nref, 1);
469469
capsnap->ci = ci;
470470
INIT_LIST_HEAD(&capsnap->ci_item);

‎fs/nfs/nfs4state.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
590590
state->owner = owner;
591591
atomic_inc(&owner->so_count);
592592
list_add(&state->inode_states, &nfsi->open_states);
593-
state->inode = igrab(inode);
593+
ihold(inode);
594+
state->inode = inode;
594595
spin_unlock(&inode->i_lock);
595596
/* Note: The reclaim code dictates that we add stateless
596597
* and read-only stateids to the end of the list */

0 commit comments

Comments
 (0)