From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10.y 1/5] btrfs: have proper error handling in btrfs_init_reloc_root
Date: Sun, 6 Sep 2026 13:18:58 -0400 [thread overview]
Message-ID: <20260906171902.1684623-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090300-visible-upwind-24ae@gregkh>
From: Josef Bacik <josef@toxicpanda.com>
[ Upstream commit 00bb36a0e76ab7e94bdd70d561baf25f9bc1415d ]
create_reloc_root will return errors in the future, and __add_reloc_root
can return ENOMEM or EEXIST, so handle these errors properly.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: 6d8ba4572922 ("btrfs: drop recovered reloc root refs on recovery failure")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/relocation.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 5b921e6ed94e2..b0d34879e267f 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -878,9 +878,15 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
reloc_root = create_reloc_root(trans, root, root->root_key.objectid);
if (clear_rsv)
trans->block_rsv = rsv;
+ if (IS_ERR(reloc_root))
+ return PTR_ERR(reloc_root);
ret = __add_reloc_root(reloc_root);
- BUG_ON(ret < 0);
+ if (ret) {
+ /* Pairs with create_reloc_root */
+ btrfs_put_root(reloc_root);
+ return ret;
+ }
root->reloc_root = btrfs_grab_root(reloc_root);
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-09-06 17:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 13:24 FAILED: patch "[PATCH] btrfs: drop recovered reloc root refs on recovery failure" failed to apply to 5.10-stable tree gregkh
2026-09-06 17:18 ` Sasha Levin [this message]
2026-09-06 17:18 ` [PATCH 5.10.y 2/5] btrfs: handle __add_reloc_root failures in btrfs_recover_relocation Sasha Levin
2026-09-06 17:19 ` [PATCH 5.10.y 3/5] btrfs: do not panic in __add_reloc_root Sasha Levin
2026-09-06 17:19 ` [PATCH 5.10.y 4/5] btrfs: rename ret to err in btrfs_recover_relocation() Sasha Levin
2026-09-06 17:19 ` [PATCH 5.10.y 5/5] btrfs: drop recovered reloc root refs on recovery failure Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260906171902.1684623-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox