Skip to content

Commit 26b06a6

Browse files
committed
GFS2: Wait properly when flushing the ail list
The ail flush code has always relied upon log flushing to prevent it from spinning needlessly. This fixes it to wait on the last I/O request submitted (we don't need to wait for all of it) instead of either spinning with io_schedule or sleeping. As a result cpu usage of gfs2_logd is much reduced with certain workloads. Reported-by: Abhijith Das <adas@redhat.com> Tested-by: Abhijith Das <adas@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 6d3117b commit 26b06a6

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

‎fs/gfs2/log.c‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,27 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp)
228228
return ret;
229229
}
230230

231+
static void gfs2_ail1_wait(struct gfs2_sbd *sdp)
232+
{
233+
struct gfs2_ail *ai;
234+
struct gfs2_bufdata *bd;
235+
struct buffer_head *bh;
236+
237+
spin_lock(&sdp->sd_ail_lock);
238+
list_for_each_entry_reverse(ai, &sdp->sd_ail1_list, ai_list) {
239+
list_for_each_entry(bd, &ai->ai_ail1_list, bd_ail_st_list) {
240+
bh = bd->bd_bh;
241+
if (!buffer_locked(bh))
242+
continue;
243+
get_bh(bh);
244+
spin_unlock(&sdp->sd_ail_lock);
245+
wait_on_buffer(bh);
246+
brelse(bh);
247+
return;
248+
}
249+
}
250+
spin_unlock(&sdp->sd_ail_lock);
251+
}
231252

232253
/**
233254
* gfs2_ail2_empty_one - Check whether or not a trans in the AIL has been synced
@@ -878,9 +899,9 @@ void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
878899
gfs2_log_flush(sdp, NULL);
879900
for (;;) {
880901
gfs2_ail1_start(sdp);
902+
gfs2_ail1_wait(sdp);
881903
if (gfs2_ail1_empty(sdp))
882904
break;
883-
msleep(10);
884905
}
885906
}
886907

@@ -920,12 +941,14 @@ int gfs2_logd(void *data)
920941

921942
if (gfs2_ail_flush_reqd(sdp)) {
922943
gfs2_ail1_start(sdp);
923-
io_schedule();
944+
gfs2_ail1_wait(sdp);
924945
gfs2_ail1_empty(sdp);
925946
gfs2_log_flush(sdp, NULL);
926947
}
927948

928-
wake_up(&sdp->sd_log_waitq);
949+
if (!gfs2_ail_flush_reqd(sdp))
950+
wake_up(&sdp->sd_log_waitq);
951+
929952
t = gfs2_tune_get(sdp, gt_logd_secs) * HZ;
930953
if (freezing(current))
931954
refrigerator();

0 commit comments

Comments
 (0)