• Andrew Morton's avatar
    [PATCH] fix ext3 BUG due to race with truncate · 81eb6906
    Andrew Morton authored
    When ext3_writepage races with truncate, block_write_full_page() will see
    that the page is outside i_size and will bale out with -EIO.  But
    ext3_writepage() will ignore this and will proceed to add the buffers to the
    transaction.
    
    Later, kjournald tries to write them out and goes BUG() because those buffers
    are not mapped to disk.
    
    The fix is to not attach the buffers to the transaction in ext3_writepage()
    if block_write_full_page() failed.
    
    So far so good, but that page now has dirty, unmapped buffers (the buffers
    were attached in a dirty state by ext3_writepage()).  So teach
    block_write_full_page() to clean the buffers against the page if it is wholly
    outside i_size.
    
    (A simpler fix to all of this mught be to just bale out of ext3_writepage()
    if the page is outside i_size.  But that is racy against
    block_write_full_page()'s subsequent execution of the same comparison).
    81eb6906
inode.c 84.2 KB