• Chris Mason's avatar
    Btrfs: fix race between mmap writes and compression · 4adaa611
    Chris Mason authored
    Btrfs uses page_mkwrite to ensure stable pages during
    crc calculations and mmap workloads.  We call clear_page_dirty_for_io
    before we do any crcs, and this forces any application with the file
    mapped to wait for the crc to finish before it is allowed to change
    the file.
    
    With compression on, the clear_page_dirty_for_io step is happening after
    we've compressed the pages.  This means the applications might be
    changing the pages while we are compressing them, and some of those
    modifications might not hit the disk.
    
    This commit adds the clear_page_dirty_for_io before compression starts
    and makes sure to redirty the page if we have to fallback to
    uncompressed IO as well.
    Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
    Reported-by: default avatarAlexandre Oliva <oliva@gnu.org>
    cc: stable@vger.kernel.org
    4adaa611
extent_io.h 12.6 KB