Skip to content

Commit 2cbd806

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix freeze consistency check in gfs2_trans_add_meta
Function gfs2_trans_add_meta() checks for the SDF_FROZEN flag to make sure that no buffers are added to a transaction while the filesystem is frozen. With the recent freeze/thaw rework, the SDF_FROZEN flag is cleared after thaw_super() is called, which is sufficient for serializing freeze/thaw. However, other filesystem operations started after thaw_super() may now be calling gfs2_trans_add_meta() before the SDF_FROZEN flag is cleared, which will trigger the SDF_FROZEN check in gfs2_trans_add_meta(). Fix that by checking the s_writers.frozen state instead. In addition, make sure not to call gfs2_assert_withdraw() with the sd_log_lock spin lock held. Check for a withdrawn filesystem before checking for a frozen filesystem, and don't pin/add buffers to the current transaction in case of a failure in either case. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
1 parent 94c7695 commit 2cbd806

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fs/gfs2/trans.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
230230
{
231231

232232
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
233+
struct super_block *sb = sdp->sd_vfs;
233234
struct gfs2_bufdata *bd;
234235
struct gfs2_meta_header *mh;
235236
struct gfs2_trans *tr = current->journal_info;
237+
bool withdraw = false;
236238

237239
lock_buffer(bh);
238240
if (buffer_pinned(bh)) {
@@ -266,13 +268,15 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
266268
(unsigned long long)bd->bd_bh->b_blocknr);
267269
BUG();
268270
}
269-
if (unlikely(test_bit(SDF_FROZEN, &sdp->sd_flags))) {
270-
fs_info(sdp, "GFS2:adding buf while frozen\n");
271-
gfs2_assert_withdraw(sdp, 0);
272-
}
273271
if (unlikely(gfs2_withdrawn(sdp))) {
274272
fs_info(sdp, "GFS2:adding buf while withdrawn! 0x%llx\n",
275273
(unsigned long long)bd->bd_bh->b_blocknr);
274+
goto out_unlock;
275+
}
276+
if (unlikely(sb->s_writers.frozen == SB_FREEZE_COMPLETE)) {
277+
fs_info(sdp, "GFS2:adding buf while frozen\n");
278+
withdraw = true;
279+
goto out_unlock;
276280
}
277281
gfs2_pin(sdp, bd->bd_bh);
278282
mh->__pad0 = cpu_to_be64(0);
@@ -281,6 +285,8 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
281285
tr->tr_num_buf_new++;
282286
out_unlock:
283287
gfs2_log_unlock(sdp);
288+
if (withdraw)
289+
gfs2_assert_withdraw(sdp, 0);
284290
out:
285291
unlock_buffer(bh);
286292
}

0 commit comments

Comments
 (0)