Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: clean up target device if block group marking fails
@ 2026-08-08  6:38 Guanghui Yang
  2026-08-08 23:23 ` Qu Wenruo
  0 siblings, 1 reply; 2+ messages in thread
From: Guanghui Yang @ 2026-08-08  6:38 UTC (permalink / raw)
  To: Chris Mason, David Sterba; +Cc: linux-btrfs, linux-kernel, Guanghui Yang

btrfs_dev_replace_start() adds the replacement target to the device
list before marking block groups to copy. If marking fails, returning
directly leaves the target linked and keeps the device accounting
incremented.

Jump to the existing cleanup path so the target device is removed and
released on failure.

The issue was found by a failure-path metadata residual analyzer and
verified with targeted failure injection on v6.14.

Assisted-by: Codex:gpt-5
Signed-off-by: Guanghui Yang <3497809730@qq.com>
---
 fs/btrfs/dev-replace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 318ddb790..bf0b78790 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -626,7 +626,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
 
 	ret = mark_block_group_to_copy(fs_info, src_device);
 	if (ret)
-		return ret;
+		goto leave;
 
 	down_write(&dev_replace->rwsem);
 	dev_replace->replace_task = current;
-- 
2.53.0


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

end of thread, other threads:[~2026-08-08 23:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08  6:38 [PATCH] btrfs: clean up target device if block group marking fails Guanghui Yang
2026-08-08 23:23 ` Qu Wenruo

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