• Dave Chinner's avatar
    xfs: write failure beyond EOF truncates too much data · 72ab70a1
    Dave Chinner authored
    If we fail a write beyond EOF and have to handle it in
    xfs_vm_write_begin(), we truncate the inode back to the current inode
    size. This doesn't take into account the fact that we may have
    already made successful writes to the same page (in the case of block
    size < page size) and hence we can truncate the page cache away from
    blocks with valid data in them. If these blocks are delayed
    allocation blocks, we now have a mismatch between the page cache and
    the extent tree, and this will trigger - at minimum - a delayed
    block count mismatch assert when the inode is evicted from the cache.
    We can also trip over it when block mapping for direct IO - this is
    the most common symptom seen from fsx and fsstress when run from
    xfstests.
    
    Fix it by only truncating away the exact range we are updating state
    for in this write_begin call.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Tested-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    72ab70a1
xfs_aops.c 44 KB