public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: don't clobber errors in add_remap_tree_entries()
@ 2026-04-08 13:13 Mark Harmstone
  2026-04-13 18:48 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Harmstone @ 2026-04-08 13:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Mark Harmstone, Mark Harmstone

From: Mark Harmstone <maharmstone@fb.com>

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>
---
 fs/btrfs/relocation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index ad433b7ca919aa..a7cf5d9cf1de0d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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;
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: don't clobber errors in add_remap_tree_entries()
  2026-04-08 13:13 [PATCH] btrfs: don't clobber errors in add_remap_tree_entries() Mark Harmstone
@ 2026-04-13 18:48 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2026-04-13 18:48 UTC (permalink / raw)
  To: Mark Harmstone; +Cc: linux-btrfs, Mark Harmstone

On Wed, Apr 08, 2026 at 02:13:20PM +0100, Mark Harmstone wrote:
> From: Mark Harmstone <maharmstone@fb.com>
> 
> 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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-13 18:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 13:13 [PATCH] btrfs: don't clobber errors in add_remap_tree_entries() Mark Harmstone
2026-04-13 18:48 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox