From: Johannes Thumshirn <jth@kernel.org>
To: linux-btrfs@vger.kernel.org
Cc: Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH v2 3/3] btrfs: zoned: don't hold space_info lock on zoned allocation
Date: Tue, 24 Jun 2025 11:37:10 +0200 [thread overview]
Message-ID: <20250624093710.18685-4-jth@kernel.org> (raw)
In-Reply-To: <20250624093710.18685-1-jth@kernel.org>
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
The zoned extent allocator holds 'struct btrfs_space_info::lock' nearly
over the entirety of the allocation process, but nothing in
do_allocation_zoned() is actually accessing fields of 'struct
btrfs_space_info'.
Furthermore taking lock_stat snapshots in performance testing, always shows
the space_info::lock as the most contented lock in the entire system.
Remove locking the space_info lock during do_allocation_zoned() to reduce
lock contention.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.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 39d3984153a2..e8d607877fb4 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3819,7 +3819,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;
@@ -3868,7 +3867,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
*/
}
- spin_lock(&space_info->lock);
spin_lock(&block_group->lock);
if (ret)
@@ -3966,7 +3964,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
if (ret && ffe_ctl->for_data_reloc)
WRITE_ONCE(fs_info->data_reloc_bg, 0);
spin_unlock(&block_group->lock);
- spin_unlock(&space_info->lock);
return ret;
}
--
2.49.0
prev parent reply other threads:[~2025-06-24 9:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 9:37 [PATCH v2 0/3] btrfs: zoned: reduce lock contention in zoned extent allocator Johannes Thumshirn
2025-06-24 9:37 ` [PATCH v2 1/3] btrfs: zoned: get rid of relocation_bg_lock Johannes Thumshirn
2025-06-24 12:32 ` Naohiro Aota
2025-06-25 10:28 ` Johannes Thumshirn
2025-06-24 9:37 ` [PATCH v2 2/3] btrfs: zoned: get rid of treelog_bg_lock Johannes Thumshirn
2025-06-24 9:37 ` Johannes Thumshirn [this message]
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=20250624093710.18685-4-jth@kernel.org \
--to=jth@kernel.org \
--cc=dlemoal@kernel.org \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
/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;
as well as URLs for NNTP newsgroup(s).