Skip to content

Commit 49462e2

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: release iopen glock early in evict
Before this patch, evict would clear the iopen glock's gl_object after releasing the inode glock. In the meantime, another process could reuse the same block and thus glocks for a new inode. It would lock the inode glock (exclusively), and then the iopen glock (shared). The shared locking mode doesn't provide any ordering against the evict, so by the time the iopen glock is reused, evict may not have gotten to setting gl_object to NULL. Fix that by releasing the iopen glock before the inode glock in gfs2_evict_inode. Signed-off-by: Bob Peterson <[email protected]>gl_object Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 7a92dea commit 49462e2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/gfs2/super.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,13 +1402,6 @@ static void gfs2_evict_inode(struct inode *inode)
14021402
gfs2_ordered_del_inode(ip);
14031403
clear_inode(inode);
14041404
gfs2_dir_hash_inval(ip);
1405-
if (ip->i_gl) {
1406-
glock_clear_object(ip->i_gl, ip);
1407-
wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1408-
gfs2_glock_add_to_lru(ip->i_gl);
1409-
gfs2_glock_put_eventually(ip->i_gl);
1410-
ip->i_gl = NULL;
1411-
}
14121405
if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
14131406
struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
14141407

@@ -1421,6 +1414,13 @@ static void gfs2_evict_inode(struct inode *inode)
14211414
gfs2_holder_uninit(&ip->i_iopen_gh);
14221415
gfs2_glock_put_eventually(gl);
14231416
}
1417+
if (ip->i_gl) {
1418+
glock_clear_object(ip->i_gl, ip);
1419+
wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1420+
gfs2_glock_add_to_lru(ip->i_gl);
1421+
gfs2_glock_put_eventually(ip->i_gl);
1422+
ip->i_gl = NULL;
1423+
}
14241424
}
14251425

14261426
static struct inode *gfs2_alloc_inode(struct super_block *sb)

0 commit comments

Comments
 (0)