Skip to content

Commit 7554918

Browse files
committed
GFS2: Fix bug-trap in ail flush code
The assert was being tested under the wrong lock, a legacy of the original code. Also, if it does trigger, the resulting information was not always a lot of help. This moves the patch under the correct lock and also prints out more useful information in tacking down the source of the problem. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 2f0264d commit 7554918

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

fs/gfs2/glops.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
#include "trans.h"
2929
#include "dir.h"
3030

31+
static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
32+
{
33+
fs_err(gl->gl_sbd, "AIL buffer %p: blocknr %llu state 0x%08lx mapping %p page state 0x%lx\n",
34+
bh, (unsigned long long)bh->b_blocknr, bh->b_state,
35+
bh->b_page->mapping, bh->b_page->flags);
36+
fs_err(gl->gl_sbd, "AIL glock %u:%llu mapping %p\n",
37+
gl->gl_name.ln_type, gl->gl_name.ln_number,
38+
gfs2_glock2aspace(gl));
39+
gfs2_lm_withdraw(gl->gl_sbd, "AIL error\n");
40+
}
41+
3142
/**
3243
* __gfs2_ail_flush - remove all buffers for a given lock from the AIL
3344
* @gl: the glock
@@ -41,20 +52,24 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl)
4152
struct list_head *head = &gl->gl_ail_list;
4253
struct gfs2_bufdata *bd;
4354
struct buffer_head *bh;
55+
sector_t blocknr;
4456

4557
spin_lock(&sdp->sd_ail_lock);
4658
while (!list_empty(head)) {
4759
bd = list_entry(head->next, struct gfs2_bufdata,
4860
bd_ail_gl_list);
4961
bh = bd->bd_bh;
50-
gfs2_remove_from_ail(bd);
51-
bd->bd_bh = NULL;
62+
blocknr = bh->b_blocknr;
63+
if (buffer_busy(bh))
64+
gfs2_ail_error(gl, bh);
5265
bh->b_private = NULL;
66+
gfs2_remove_from_ail(bd); /* drops ref on bh */
5367
spin_unlock(&sdp->sd_ail_lock);
5468

55-
bd->bd_blkno = bh->b_blocknr;
69+
bd->bd_bh = NULL;
70+
bd->bd_blkno = blocknr;
71+
5672
gfs2_log_lock(sdp);
57-
gfs2_assert_withdraw(sdp, !buffer_busy(bh));
5873
gfs2_trans_add_revoke(sdp, bd);
5974
gfs2_log_unlock(sdp);
6075

0 commit comments

Comments
 (0)