• Liu Bo's avatar
    Btrfs: fix unexpected cow in run_delalloc_nocow · 58113753
    Liu Bo authored
    Fstests generic/475 provides a way to fail metadata reads while
    checking if checksum exists for the inode inside run_delalloc_nocow(),
    and csum_exist_in_range() interprets error (-EIO) as inode having
    checksum and makes its caller enter the cow path.
    
    In case of free space inode, this ends up with a warning in
    cow_file_range().
    
    The same problem applies to btrfs_cross_ref_exist() since it may also
    read metadata in between.
    
    With this, run_delalloc_nocow() bails out when errors occur at the two
    places.
    
    cc: <stable@vger.kernel.org> v2.6.28+
    Fixes: 17d217fe ("Btrfs: fix nodatasum handling in balancing code")
    Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    58113753
inode.c 289 KB