• Christoph Hellwig's avatar
    btrfs: fix error handling when in a COW window in run_delalloc_nocow · 953fa5ce
    Christoph Hellwig authored
    When run_delalloc_nocow has cow_start set to a value other than (u64)-1,
    it has delayed COW writeback pending behind cur_offset.  When an error
    occurs in such a window, the range going back to cow_start and not just
    cur_offset needs to be unlocked, but only two error cases handle this
    correctly  Move the code to handle unlock the COW range to the common
    error handling label and document the logic.
    
    To make things even more complicated, cow_file_range as called by
    fallback_to_cow will unlock the range it is operating on when it fails as
    well, so we need to reset cow_start right after caling fallback_to_cow
    instead of only when it succeeded.
    Reviewed-by: default avatarBoris Burkov <boris@bur.io>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    953fa5ce
inode.c 313 KB