mm: write_cache_pages cyclic fix
authorNick Piggin <npiggin@suse.de>
Tue, 6 Jan 2009 22:39:04 +0000 (14:39 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 25 Jan 2009 00:36:26 +0000 (16:36 -0800)
commitc1496489b4fd832ca61bb17a33dfaaa0123abbcb
tree4bd70f0b3aa65428067ec79476baca4ddb4e3360
parent78dfe05e77805f2eb41d0a3f6889f203195fd5c4
mm: write_cache_pages cyclic fix

commit 31a12666d8f0c22235297e1c1575f82061480029 upstream.

In write_cache_pages, scanned == 1 is supposed to mean that cyclic
writeback has circled through zero, thus we should not circle again.
However it gets set to 1 after the first successful pagevec lookup.  This
leads to cases where not enough data gets written.

Counterexample: file with first 10 pages dirty, writeback_index == 5,
nr_to_write == 10.  Then the 5 last pages will be found, and scanned will
be set to 1, after writing those out, we will not cycle back to get the
first 5.

Rework this logic, now we'll always cycle unless we started off from index
0.  When cycling, only write out as far as 1 page before the start page
from the first cycle (so we don't write parts of the file twice).

Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/page-writeback.c