]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: don't clobber errors in add_remap_tree_entries()
authorMark Harmstone <maharmstone@fb.com>
Mon, 23 Mar 2026 17:17:01 +0000 (17:17 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 21 Apr 2026 02:01:43 +0000 (04:01 +0200)
In add_remap_tree_entries(), we only process a certain number of entries
at a time, meaning we may need to loop.

But because we weren't checking the return value of btrfs_insert_empty_items()
within the loop, this meant that if the last iteration of the loop
succeeded but a previous iteration failed, we were erroneously returning
0.

Fix this by breaking the loop early if btrfs_insert_empty_items() fails.

Fixes: b56f35560b82 ("btrfs: handle setting up relocation of block group with remap-tree")
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c

index d21742750b69d997fbbe2718008f442495c5e269..3ebaf5880125fa2e50d3b7bb5b7f1be92d03aacc 100644 (file)
@@ -3876,7 +3876,7 @@ static int add_remap_tree_entries(struct btrfs_trans_handle *trans, struct btrfs
                ret = btrfs_insert_empty_items(trans, fs_info->remap_root, path, &batch);
                btrfs_release_path(path);
 
-               if (num_entries <= max_items)
+               if (ret || num_entries <= max_items)
                        break;
 
                num_entries -= max_items;