mm: avoid resetting wb_start after each writeback round
authorJan Kara <jack@suse.cz>
Tue, 10 Aug 2010 00:20:03 +0000 (17:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:45:03 +0000 (20:45 -0700)
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>
fs/fs-writeback.c

index d5be1693ac9382f934d39d1529d0c0bd9df10b1c..30ac305e8293a3facc9a88e751cfcf88e1c5d9af 100644 (file)
@@ -530,7 +530,8 @@ void writeback_inodes_wb(struct bdi_writeback *wb,
 {
        int ret = 0;
 
-       wbc->wb_start = jiffies; /* livelock avoidance */
+       if (!wbc->wb_start)
+               wbc->wb_start = jiffies; /* livelock avoidance */
        spin_lock(&inode_lock);
        if (!wbc->for_kupdate || list_empty(&wb->b_io))
                queue_io(wb, wbc->older_than_this);
@@ -559,7 +560,6 @@ static void __writeback_inodes_sb(struct super_block *sb,
 {
        WARN_ON(!rwsem_is_locked(&sb->s_umount));
 
-       wbc->wb_start = jiffies; /* livelock avoidance */
        spin_lock(&inode_lock);
        if (!wbc->for_kupdate || list_empty(&wb->b_io))
                queue_io(wb, wbc->older_than_this);
@@ -625,6 +625,7 @@ static long wb_writeback(struct bdi_writeback *wb,
                wbc.range_end = LLONG_MAX;
        }
 
+       wbc.wb_start = jiffies; /* livelock avoidance */
        for (;;) {
                /*
                 * Stop writeback when nr_pages has been consumed