• Filipe Manana's avatar
    btrfs: fix unexpected error path when reflinking an inline extent · 1f4613cd
    Filipe Manana authored
    When reflinking an inline extent, we assert that its file offset is 0 and
    that its uncompressed length is not greater than the sector size. We then
    return an error if one of those conditions is not satisfied. However we
    use a return statement, which results in returning from btrfs_clone()
    without freeing the path and buffer that were allocated before, as well as
    not clearing the flag BTRFS_INODE_NO_DELALLOC_FLUSH for the destination
    inode.
    
    Fix that by jumping to the 'out' label instead, and also add a WARN_ON()
    for each condition so that in case assertions are disabled, we get to
    known which of the unexpected conditions triggered the error.
    
    Fixes: a61e1e0d ("Btrfs: simplify inline extent handling when doing reflinks")
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1f4613cd
reflink.c 27.7 KB