diff options
author | Jan Kara <jack@suse.cz> | 2010-08-09 20:20:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:45:03 -0400 |
commit | 7624ee72aa09334af072853457a5d46d9901c3f8 (patch) | |
tree | 046321fdf7f46c38a6e6d686c1cd962e70149c94 /fs | |
parent | d9f8984c2c23b91e202a764fe4b15041a29a201a (diff) |
mm: avoid resetting wb_start after each writeback round
WB_SYNC_NONE writeback is done in rounds of 1024 pages so that we don't
write out some huge inode for too long while starving writeout of other
inodes. To avoid livelocks, we record time we started writeback in
wbc->wb_start and do not write out inodes which were dirtied after this
time. But currently, writeback_inodes_wb() resets wb_start each time it
is called thus effectively invalidating this logic and making any
WB_SYNC_NONE writeback prone to livelocks.
This patch makes sure wb_start is set only once when we start writeback.
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Acked-by: Jens Axboe <jaxboe@fusionio.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs-writeback.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d5be1693ac93..30ac305e8293 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -530,7 +530,8 @@ void writeback_inodes_wb(struct bdi_writeback *wb, | |||
530 | { | 530 | { |
531 | int ret = 0; | 531 | int ret = 0; |
532 | 532 | ||
533 | wbc->wb_start = jiffies; /* livelock avoidance */ | 533 | if (!wbc->wb_start) |
534 | wbc->wb_start = jiffies; /* livelock avoidance */ | ||
534 | spin_lock(&inode_lock); | 535 | spin_lock(&inode_lock); |
535 | if (!wbc->for_kupdate || list_empty(&wb->b_io)) | 536 | if (!wbc->for_kupdate || list_empty(&wb->b_io)) |
536 | queue_io(wb, wbc->older_than_this); | 537 | queue_io(wb, wbc->older_than_this); |
@@ -559,7 +560,6 @@ static void __writeback_inodes_sb(struct super_block *sb, | |||
559 | { | 560 | { |
560 | WARN_ON(!rwsem_is_locked(&sb->s_umount)); | 561 | WARN_ON(!rwsem_is_locked(&sb->s_umount)); |
561 | 562 | ||
562 | wbc->wb_start = jiffies; /* livelock avoidance */ | ||
563 | spin_lock(&inode_lock); | 563 | spin_lock(&inode_lock); |
564 | if (!wbc->for_kupdate || list_empty(&wb->b_io)) | 564 | if (!wbc->for_kupdate || list_empty(&wb->b_io)) |
565 | queue_io(wb, wbc->older_than_this); | 565 | queue_io(wb, wbc->older_than_this); |
@@ -625,6 +625,7 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
625 | wbc.range_end = LLONG_MAX; | 625 | wbc.range_end = LLONG_MAX; |
626 | } | 626 | } |
627 | 627 | ||
628 | wbc.wb_start = jiffies; /* livelock avoidance */ | ||
628 | for (;;) { | 629 | for (;;) { |
629 | /* | 630 | /* |
630 | * Stop writeback when nr_pages has been consumed | 631 | * Stop writeback when nr_pages has been consumed |