Skip to content

Commit 763766c

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: dequeue iopen holder in gfs2_inode_lookup error
Before this patch, if function gfs2_inode_lookup encountered an error after it had locked the iopen glock, it never unlocked it, relying on the evict code to do the cleanup. The evict code then took the inode glock while holding the iopen glock, which violates the locking order. For example, (1) node A does a gfs2_inode_lookup that fails, leaving the iopen glock locked. (2) node B calls delete_work_func -> gfs2_lookup_by_inum -> gfs2_inode_lookup. It locks the inode glock and blocks trying to lock the iopen glock, which is held by node A. (3) node A eventually calls gfs2_evict_inode -> evict_should_delete. It blocks trying to lock the inode glock, which is now held by node B. This patch introduces error handling to function gfs2_inode_lookup so it properly dequeues held iopen glocks on errors. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent b016d9a commit 763766c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fs/gfs2/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
225225
return inode;
226226

227227
fail:
228+
if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
229+
glock_clear_object(ip->i_iopen_gh.gh_gl, ip);
230+
gfs2_glock_dq_uninit(&ip->i_iopen_gh);
231+
}
228232
if (io_gl)
229233
gfs2_glock_put(io_gl);
230234
if (gfs2_holder_initialized(&i_gh))

0 commit comments

Comments
 (0)