Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

writeback: fix occasional slow sync(1)

In case when system contains no dirty pages, wakeup_flusher_threads() will
submit WB_SYNC_NONE writeback for 0 pages so wb_writeback() exits
immediately without doing anything, even though there are dirty inodes in
the system. Thus sync(1) will write all the dirty inodes from a
WB_SYNC_ALL writeback pass which is slow.

Fix the problem by using get_nr_dirty_pages() in wakeup_flusher_threads()
instead of calculating number of dirty pages manually. That function also
takes number of dirty inodes into account.

Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Paul Taysom <taysom@chromium.org>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Kara and committed by
Linus Torvalds
47df3dde 7cb2ef56

+2 -4
+2 -4
fs/fs-writeback.c
··· 1049 1049 { 1050 1050 struct backing_dev_info *bdi; 1051 1051 1052 - if (!nr_pages) { 1053 - nr_pages = global_page_state(NR_FILE_DIRTY) + 1054 - global_page_state(NR_UNSTABLE_NFS); 1055 - } 1052 + if (!nr_pages) 1053 + nr_pages = get_nr_dirty_pages(); 1056 1054 1057 1055 rcu_read_lock(); 1058 1056 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {