diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2011-09-07 05:33:25 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2011-10-21 07:39:41 -0400 |
commit | b5b24d7aeb9608935786369ac2d3e9f362877d55 (patch) | |
tree | 2043123df7a6e6ca367b24cb3442ee50314cdee0 /fs/gfs2/glops.c | |
parent | 70b0c3656f12964a6dac104214c904c66e626058 (diff) |
GFS2: Fix AIL flush issue during fsync
Unfortunately, it is not enough to just ignore locked buffers during
the AIL flush from fsync. We need to be able to ignore all buffers
which are locked, dirty or pinned at this stage as they might have
been added subsequent to the log flush earlier in the fsync function.
In addition, this means that we no longer need to rely on i_mutex to
keep out writes during fsync, so we can, as a side-effect, remove
that protection too.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Tested-By: Abhijith Das <adas@redhat.com>
Diffstat (limited to 'fs/gfs2/glops.c')
-rw-r--r-- | fs/gfs2/glops.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 951541b6234c..78418b4fa857 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c | |||
@@ -42,41 +42,41 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh) | |||
42 | /** | 42 | /** |
43 | * __gfs2_ail_flush - remove all buffers for a given lock from the AIL | 43 | * __gfs2_ail_flush - remove all buffers for a given lock from the AIL |
44 | * @gl: the glock | 44 | * @gl: the glock |
45 | * @fsync: set when called from fsync (not all buffers will be clean) | ||
45 | * | 46 | * |
46 | * None of the buffers should be dirty, locked, or pinned. | 47 | * None of the buffers should be dirty, locked, or pinned. |
47 | */ | 48 | */ |
48 | 49 | ||
49 | static void __gfs2_ail_flush(struct gfs2_glock *gl, unsigned long b_state) | 50 | static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync) |
50 | { | 51 | { |
51 | struct gfs2_sbd *sdp = gl->gl_sbd; | 52 | struct gfs2_sbd *sdp = gl->gl_sbd; |
52 | struct list_head *head = &gl->gl_ail_list; | 53 | struct list_head *head = &gl->gl_ail_list; |
53 | struct gfs2_bufdata *bd; | 54 | struct gfs2_bufdata *bd, *tmp; |
54 | struct buffer_head *bh; | 55 | struct buffer_head *bh; |
56 | const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock); | ||
55 | sector_t blocknr; | 57 | sector_t blocknr; |
56 | 58 | ||
59 | gfs2_log_lock(sdp); | ||
57 | spin_lock(&sdp->sd_ail_lock); | 60 | spin_lock(&sdp->sd_ail_lock); |
58 | while (!list_empty(head)) { | 61 | list_for_each_entry_safe(bd, tmp, head, bd_ail_gl_list) { |
59 | bd = list_entry(head->next, struct gfs2_bufdata, | ||
60 | bd_ail_gl_list); | ||
61 | bh = bd->bd_bh; | 62 | bh = bd->bd_bh; |
62 | blocknr = bh->b_blocknr; | 63 | if (bh->b_state & b_state) { |
63 | if (bh->b_state & b_state) | 64 | if (fsync) |
65 | continue; | ||
64 | gfs2_ail_error(gl, bh); | 66 | gfs2_ail_error(gl, bh); |
67 | } | ||
68 | blocknr = bh->b_blocknr; | ||
65 | bh->b_private = NULL; | 69 | bh->b_private = NULL; |
66 | gfs2_remove_from_ail(bd); /* drops ref on bh */ | 70 | gfs2_remove_from_ail(bd); /* drops ref on bh */ |
67 | spin_unlock(&sdp->sd_ail_lock); | ||
68 | 71 | ||
69 | bd->bd_bh = NULL; | 72 | bd->bd_bh = NULL; |
70 | bd->bd_blkno = blocknr; | 73 | bd->bd_blkno = blocknr; |
71 | 74 | ||
72 | gfs2_log_lock(sdp); | ||
73 | gfs2_trans_add_revoke(sdp, bd); | 75 | gfs2_trans_add_revoke(sdp, bd); |
74 | gfs2_log_unlock(sdp); | ||
75 | |||
76 | spin_lock(&sdp->sd_ail_lock); | ||
77 | } | 76 | } |
78 | gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count)); | 77 | BUG_ON(!fsync && atomic_read(&gl->gl_ail_count)); |
79 | spin_unlock(&sdp->sd_ail_lock); | 78 | spin_unlock(&sdp->sd_ail_lock); |
79 | gfs2_log_unlock(sdp); | ||
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
@@ -99,13 +99,13 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl) | |||
99 | BUG_ON(current->journal_info); | 99 | BUG_ON(current->journal_info); |
100 | current->journal_info = &tr; | 100 | current->journal_info = &tr; |
101 | 101 | ||
102 | __gfs2_ail_flush(gl, (1ul << BH_Dirty)|(1ul << BH_Pinned)|(1ul << BH_Lock)); | 102 | __gfs2_ail_flush(gl, 0); |
103 | 103 | ||
104 | gfs2_trans_end(sdp); | 104 | gfs2_trans_end(sdp); |
105 | gfs2_log_flush(sdp, NULL); | 105 | gfs2_log_flush(sdp, NULL); |
106 | } | 106 | } |
107 | 107 | ||
108 | void gfs2_ail_flush(struct gfs2_glock *gl) | 108 | void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync) |
109 | { | 109 | { |
110 | struct gfs2_sbd *sdp = gl->gl_sbd; | 110 | struct gfs2_sbd *sdp = gl->gl_sbd; |
111 | unsigned int revokes = atomic_read(&gl->gl_ail_count); | 111 | unsigned int revokes = atomic_read(&gl->gl_ail_count); |
@@ -117,7 +117,7 @@ void gfs2_ail_flush(struct gfs2_glock *gl) | |||
117 | ret = gfs2_trans_begin(sdp, 0, revokes); | 117 | ret = gfs2_trans_begin(sdp, 0, revokes); |
118 | if (ret) | 118 | if (ret) |
119 | return; | 119 | return; |
120 | __gfs2_ail_flush(gl, (1ul << BH_Dirty)|(1ul << BH_Pinned)); | 120 | __gfs2_ail_flush(gl, fsync); |
121 | gfs2_trans_end(sdp); | 121 | gfs2_trans_end(sdp); |
122 | gfs2_log_flush(sdp, NULL); | 122 | gfs2_log_flush(sdp, NULL); |
123 | } | 123 | } |