aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2013-09-11 17:22:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:57:55 -0400
commit47df3ddedd22c3f8e68aff831edb7921937674a2 (patch)
tree3a8b82782ef6c90e7974063b642e5bbab04fd55e
parent7cb2ef56e6a8b7b368b2e883a0a47d02fed66911 (diff)
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>
-rw-r--r--fs/fs-writeback.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 68851ff2fd41..87d778118027 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1049,10 +1049,8 @@ void wakeup_flusher_threads(long nr_pages, enum wb_reason reason)
1049{ 1049{
1050 struct backing_dev_info *bdi; 1050 struct backing_dev_info *bdi;
1051 1051
1052 if (!nr_pages) { 1052 if (!nr_pages)
1053 nr_pages = global_page_state(NR_FILE_DIRTY) + 1053 nr_pages = get_nr_dirty_pages();
1054 global_page_state(NR_UNSTABLE_NFS);
1055 }
1056 1054
1057 rcu_read_lock(); 1055 rcu_read_lock();
1058 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { 1056 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {