Skip to content

Commit b1676cb

Browse files
committed
gfs2: Withdraw in gfs2_ail1_flush if write_cache_pages fails
Before this patch, function gfs2_ail1_start_one would return any errors it received from write_cache_pages (except -EBUSY) but it did not withdraw. Since function gfs2_ail1_flush just checks for the bad return code and loops, the loop might potentially never end. This patch adds some logic to allow it to exit the loop and withdraw properly when errors are received from write_cache_pages. Signed-off-by: Bob Peterson <[email protected]> Reviewed-by: Andreas Gruenbacher <[email protected]>
1 parent 9ff7828 commit b1676cb

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

fs/gfs2/log.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ __acquires(&sdp->sd_ail_lock)
9696
struct address_space *mapping;
9797
struct gfs2_bufdata *bd, *s;
9898
struct buffer_head *bh;
99+
int ret = 0;
99100

100101
list_for_each_entry_safe_reverse(bd, s, &tr->tr_ail1_list, bd_ail_st_list) {
101102
bh = bd->bd_bh;
@@ -128,14 +129,14 @@ __acquires(&sdp->sd_ail_lock)
128129
if (!mapping)
129130
continue;
130131
spin_unlock(&sdp->sd_ail_lock);
131-
generic_writepages(mapping, wbc);
132+
ret = generic_writepages(mapping, wbc);
132133
spin_lock(&sdp->sd_ail_lock);
133-
if (wbc->nr_to_write <= 0)
134+
if (ret || wbc->nr_to_write <= 0)
134135
break;
135-
return 1;
136+
return -EBUSY;
136137
}
137138

138-
return 0;
139+
return ret;
139140
}
140141

141142

@@ -153,6 +154,7 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
153154
struct list_head *head = &sdp->sd_ail1_list;
154155
struct gfs2_trans *tr;
155156
struct blk_plug plug;
157+
int ret = 0;
156158

157159
trace_gfs2_ail_flush(sdp, wbc, 1);
158160
blk_start_plug(&plug);
@@ -161,12 +163,16 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
161163
list_for_each_entry_reverse(tr, head, tr_list) {
162164
if (wbc->nr_to_write <= 0)
163165
break;
164-
if (gfs2_ail1_start_one(sdp, wbc, tr) && !gfs2_withdrawn(sdp))
165-
goto restart;
166+
ret = gfs2_ail1_start_one(sdp, wbc, tr);
167+
if (ret) {
168+
if (ret == -EBUSY)
169+
goto restart;
170+
break;
171+
}
166172
}
167173
spin_unlock(&sdp->sd_ail_lock);
168174
blk_finish_plug(&plug);
169-
if (test_bit(SDF_WITHDRAWING, &sdp->sd_flags))
175+
if (ret)
170176
gfs2_withdraw(sdp);
171177
trace_gfs2_ail_flush(sdp, wbc, 0);
172178
}

0 commit comments

Comments
 (0)