Skip to content

Commit f4e2f5e

Browse files
author
Andreas Gruenbacher
committed
gfs2: Grab glock reference sooner in gfs2_add_revoke
This patch rearranges gfs2_add_revoke so that the extra glock reference is added earlier on in the function to avoid races in which the glock is freed before the new reference is taken. Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent c9cb9e3 commit f4e2f5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/gfs2/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,13 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
669669
struct buffer_head *bh = bd->bd_bh;
670670
struct gfs2_glock *gl = bd->bd_gl;
671671

672+
sdp->sd_log_num_revoke++;
673+
if (atomic_inc_return(&gl->gl_revokes) == 1)
674+
gfs2_glock_hold(gl);
672675
bh->b_private = NULL;
673676
bd->bd_blkno = bh->b_blocknr;
674677
gfs2_remove_from_ail(bd); /* drops ref on bh */
675678
bd->bd_bh = NULL;
676-
sdp->sd_log_num_revoke++;
677-
if (atomic_inc_return(&gl->gl_revokes) == 1)
678-
gfs2_glock_hold(gl);
679679
set_bit(GLF_LFLUSH, &gl->gl_flags);
680680
list_add(&bd->bd_list, &sdp->sd_log_revokes);
681681
}

0 commit comments

Comments
 (0)