summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2024-05-14 15:36:35 +0100
committerDavid Sterba <dsterba@suse.com>2024-05-15 17:57:39 +0200
commitdddff821b660e08eb8418cfd3909e61204804534 (patch)
tree2265392bc48026849454257df67a1a3584d36a33 /fs/btrfs
parentb4e585fffc1cf877112ed231a91f089e85688c2a (diff)
downloadlinux-stable-dddff821b660e08eb8418cfd3909e61204804534.tar.gz
linux-stable-dddff821b660e08eb8418cfd3909e61204804534.tar.bz2
linux-stable-dddff821b660e08eb8418cfd3909e61204804534.zip
btrfs: fix end of tree detection when searching for data extent ref
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: 1618aa3c2e01 ("btrfs: simplify return variables in lookup_extent_data_ref()") Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 47d48233b592..3774c191e36d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -477,7 +477,7 @@ again:
if (path->slots[0] >= nritems) {
ret = btrfs_next_leaf(root, path);
if (ret) {
- if (ret > 1)
+ if (ret > 0)
return -ENOENT;
return ret;
}