From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
To: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Subject: [PATCH] btrfs: zoned: remove redundant space_info lock and variable in do_allocation_zoned
Date: Mon, 12 Jan 2026 15:40:40 +0000 [thread overview]
Message-ID: <20260112154040.35746-1-jiashengjiangcool@gmail.com> (raw)
In do_allocation_zoned, the code acquires space_info->lock followed by
block_group->lock. However, the critical section does not access or
modify any members of the space_info structure, making the lock
acquisition and the space_info local variable redundant.
This unnecessary locking also creates a potential circular wait deadlock
(AB-BA) risk. Other paths, such as background reclaim or space reporting,
could acquire block_group->lock and subsequently attempt to acquire
space_info->lock to update global counters.
This behavior diverges from other Zoned-specific paths like
__btrfs_add_free_space_zoned which only rely on block_group->lock.
Removing the acquisition of space_info->lock and its corresponding
definition in do_allocation_zoned eliminates the deadlock risk and
improves concurrency by reducing contention on the global space_info lock.
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
fs/btrfs/extent-tree.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e4cae34620d1..43d78056c274 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3839,7 +3839,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
struct btrfs_block_group **bg_ret)
{
struct btrfs_fs_info *fs_info = block_group->fs_info;
- struct btrfs_space_info *space_info = block_group->space_info;
struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
u64 start = block_group->start;
u64 num_bytes = ffe_ctl->num_bytes;
@@ -3900,7 +3899,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
*/
}
- spin_lock(&space_info->lock);
spin_lock(&block_group->lock);
spin_lock(&fs_info->treelog_bg_lock);
spin_lock(&fs_info->relocation_bg_lock);
@@ -4002,7 +4000,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
spin_unlock(&fs_info->relocation_bg_lock);
spin_unlock(&fs_info->treelog_bg_lock);
spin_unlock(&block_group->lock);
- spin_unlock(&space_info->lock);
return ret;
}
--
2.25.1
next reply other threads:[~2026-01-12 15:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 15:40 Jiasheng Jiang [this message]
2026-01-12 18:56 ` [PATCH] btrfs: zoned: remove redundant space_info lock and variable in do_allocation_zoned Boris Burkov
2026-01-12 20:22 ` [PATCH v2] " Jiasheng Jiang
2026-01-13 18:29 ` Boris Burkov
2026-01-14 11:24 ` Johannes Thumshirn
2026-01-14 13:09 ` Naohiro Aota
2026-01-14 14:44 ` [PATCH v3] " Jiasheng Jiang
2026-02-04 14:40 ` David Sterba
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=20260112154040.35746-1-jiashengjiangcool@gmail.com \
--to=jiashengjiangcool@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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