mm: write_cache_pages integrity fix

Previous thread: mm: write_cache_pages cyclic fix by Linux Kernel Mailing List on Tuesday, January 6, 2009 - 5:59 pm. (1 message)

Next thread: mm: write_cache_pages terminate quickly by Linux Kernel Mailing List on Tuesday, January 6, 2009 - 5:59 pm. (1 message)
From: Linux Kernel Mailing List
Date: Tuesday, January 6, 2009 - 5:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=05fe47...
Commit:     05fe478dd04e02fa230c305ab9b5616669821dd3
Parent:     00266770b8b3a6a77f896ca501a0613739086832
Author:     Nick Piggin <npiggin@suse.de>
AuthorDate: Tue Jan 6 14:39:08 2009 -0800
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Tue Jan 6 15:58:59 2009 -0800

    mm: write_cache_pages integrity fix
    
    In write_cache_pages, nr_to_write is heeded even for data-integrity syncs,
    so the function will return success after writing out nr_to_write pages,
    even if that was not sufficient to guarantee data integrity.
    
    The callers tend to set it to values that could break data interity
    semantics easily in practice.  For example, nr_to_write can be set to
    mapping->nr_pages * 2, however if a file has a single, dirty page, then
    fsync is called, subsequent pages might be concurrently added and dirtied,
    then write_cache_pages might writeout two of these newly dirty pages,
    while not writing out the old page that should have been written out.
    
    Fix this by ignoring nr_to_write if it is a data integrity sync.
    
    This is a data integrity bug.
    
    The reason this has been done in the past is to avoid stalling sync
    operations behind page dirtiers.
    
     "If a file has one dirty page at offset 1000000000000000 then someone
      does an fsync() and someone else gets in first and starts madly writing
      pages at offset 0, we want to write that page at 1000000000000000.
      Somehow."
    
    What we do today is return success after an arbitrary amount of pages are
    written, whether or not we have provided the data-integrity semantics that
    the caller has asked for.  Even this doesn't actually fix all stall cases
    completely: in the above situation, if the file has a huge number of pages
    in pagecache (but not dirty), then mapping->nrpages is going to ...
Previous thread: mm: write_cache_pages cyclic fix by Linux Kernel Mailing List on Tuesday, January 6, 2009 - 5:59 pm. (1 message)

Next thread: mm: write_cache_pages terminate quickly by Linux Kernel Mailing List on Tuesday, January 6, 2009 - 5:59 pm. (1 message)