Skip to content

Commit 006a097

Browse files
htejunaxboe
authored andcommitted
writeback: sync_inodes_sb() must write out I_DIRTY_TIME inodes and always call wait_sb_inodes()
e797291 ("writeback: don't issue wb_writeback_work if clean") updated writeback path to avoid kicking writeback work items if there are no inodes to be written out; unfortunately, the avoidance logic was too aggressive and broke sync_inodes_sb(). * sync_inodes_sb() must write out I_DIRTY_TIME inodes but I_DIRTY_TIME inodes dont't contribute to bdi/wb_has_dirty_io() tests and were being skipped over. * inodes are taken off wb->b_dirty/io/more_io lists after writeback starts on them. sync_inodes_sb() skipping wait_sb_inodes() when bdi_has_dirty_io() breaks it by making it return while writebacks are in-flight. This patch fixes the breakages by * Removing bdi_has_dirty_io() shortcut from bdi_split_work_to_wbs(). The callers are already testing the condition. * Removing bdi_has_dirty_io() shortcut from sync_inodes_sb() so that it always calls into bdi_split_work_to_wbs() and wait_sb_inodes(). * Making bdi_split_work_to_wbs() consider the b_dirty_time list for WB_SYNC_ALL writebacks. Kudos to Eryu, Dave and Jan for tracking down the issue. Signed-off-by: Tejun Heo <[email protected]> Fixes: e797291 ("writeback: don't issue wb_writeback_work if clean") Link: http://lkml.kernel.org/g/[email protected] Reported-and-bisected-by: Eryu Guan <[email protected]> Cc: Dave Chinner <[email protected]> Cc: Jan Kara <[email protected]> Cc: Ted Ts'o <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c13dcf9 commit 006a097

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

fs/fs-writeback.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,15 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
844844
struct wb_iter iter;
845845

846846
might_sleep();
847-
848-
if (!bdi_has_dirty_io(bdi))
849-
return;
850847
restart:
851848
rcu_read_lock();
852849
bdi_for_each_wb(wb, bdi, &iter, next_blkcg_id) {
853-
if (!wb_has_dirty_io(wb) ||
854-
(skip_if_busy && writeback_in_progress(wb)))
850+
/* SYNC_ALL writes out I_DIRTY_TIME too */
851+
if (!wb_has_dirty_io(wb) &&
852+
(base_work->sync_mode == WB_SYNC_NONE ||
853+
list_empty(&wb->b_dirty_time)))
854+
continue;
855+
if (skip_if_busy && writeback_in_progress(wb))
855856
continue;
856857

857858
base_work->nr_pages = wb_split_bdi_pages(wb, nr_pages);
@@ -899,8 +900,7 @@ static void bdi_split_work_to_wbs(struct backing_dev_info *bdi,
899900
{
900901
might_sleep();
901902

902-
if (bdi_has_dirty_io(bdi) &&
903-
(!skip_if_busy || !writeback_in_progress(&bdi->wb))) {
903+
if (!skip_if_busy || !writeback_in_progress(&bdi->wb)) {
904904
base_work->auto_free = 0;
905905
base_work->single_wait = 0;
906906
base_work->single_done = 0;
@@ -2275,8 +2275,12 @@ void sync_inodes_sb(struct super_block *sb)
22752275
};
22762276
struct backing_dev_info *bdi = sb->s_bdi;
22772277

2278-
/* Nothing to do? */
2279-
if (!bdi_has_dirty_io(bdi) || bdi == &noop_backing_dev_info)
2278+
/*
2279+
* Can't skip on !bdi_has_dirty() because we should wait for !dirty
2280+
* inodes under writeback and I_DIRTY_TIME inodes ignored by
2281+
* bdi_has_dirty() need to be written out too.
2282+
*/
2283+
if (bdi == &noop_backing_dev_info)
22802284
return;
22812285
WARN_ON(!rwsem_is_locked(&sb->s_umount));
22822286

0 commit comments

Comments
 (0)