• Filipe Manana's avatar
    btrfs: fix end of tree detection when searching for data extent ref · dddff821
    Filipe Manana authored
    At lookup_extent_data_ref() we are incorrectly checking if we are at the
    last slot of the last leaf in the extent tree. We are returning -ENOENT
    if btrfs_next_leaf() returns a value greater than 1, but btrfs_next_leaf()
    never returns anything greater than 1:
    
    1) It returns < 0 on error;
    
    2) 0 if there is a next leaf (or a new item was added to the end of the
       current leaf after releasing the path);
    
    3) 1 if there are no more leaves (and no new items were added to the last
       leaf after releasing the path).
    
    So fix this by checking if the return value is greater than zero instead
    of being greater than one.
    
    Fixes: 1618aa3c ("btrfs: simplify return variables in lookup_extent_data_ref()")
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    dddff821
extent-tree.c 173 KB