• Nick Piggin's avatar
    mm: write_cache_pages cyclic fix · 31a12666
    Nick Piggin authored
    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: default avatarNick Piggin <npiggin@suse.de>
    Cc: Chris Mason <chris.mason@oracle.com>
    Cc: Dave Chinner <david@fromorbit.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    31a12666
page-writeback.c 36.6 KB