From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: linux-btrfs@vger.kernel.org
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH] btrfs: zoned: catch aborted trans in btrfs_zoned_reserve_data_reloc_bg
Date: Mon, 23 Feb 2026 15:38:20 +0100 [thread overview]
Message-ID: <20260223143820.89931-1-johannes.thumshirn@wdc.com> (raw)
btrfs_zoned_reserve_data_reloc_bg() is called on each mount of a file
system and allocates a new block-group, to assign it to be the dedicated
relocation target, if no pre-existing usable block-group for this task is
found.
If for some reason the transaction was aborted during the call to
btrfs_chunk_alloc() and btrfs_end_transaction() is executed, a
NULL-pointer dereference happens in btrfs_end_transaction().
Check if the transaction was aborted before calling into
btrfs_end_transaction() and if it was aborted return early.
Fixes: 694ce5e143d6 ("btrfs: zoned: reserve data_reloc block group on mount")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/zoned.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index f64b872d53ce..265947fde727 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2842,6 +2842,9 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info)
ASSERT(space_info->subgroup_id == BTRFS_SUB_GROUP_DATA_RELOC,
"space_info->subgroup_id=%d", space_info->subgroup_id);
ret = btrfs_chunk_alloc(trans, space_info, alloc_flags, CHUNK_ALLOC_FORCE);
+ if (TRANS_ABORTED(trans))
+ return;
+
btrfs_end_transaction(trans);
if (ret == 1) {
/*
--
2.53.0
next reply other threads:[~2026-02-23 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 14:38 Johannes Thumshirn [this message]
2026-02-23 15:13 ` [PATCH] btrfs: zoned: catch aborted trans in btrfs_zoned_reserve_data_reloc_bg Filipe Manana
2026-02-23 15:27 ` Johannes Thumshirn
2026-02-23 15:32 ` Filipe Manana
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=20260223143820.89931-1-johannes.thumshirn@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@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