summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiasheng Jiang <jiashengjiangcool@gmail.com>2026-01-14 17:44:50 +0300
committerDavid Sterba <dsterba@suse.com>2026-04-07 19:55:52 +0300
commit08ef56661f69d40081ef782cd6a162bb0777af74 (patch)
tree82ffc9319c5fbd965f4a4b89746a57dc4c43b074
parent6141abb7f18f381d879d98f6c200494f14e502a0 (diff)
downloadlinux-08ef56661f69d40081ef782cd6a162bb0777af74.tar.xz
btrfs: zoned: remove redundant space_info lock and variable in do_allocation_zoned()
In do_allocation_zoned(), the code acquires space_info->lock before block_group->lock. However, the critical section does not access or modify any members of the space_info structure. Thus, the lock is redundant as it provides no necessary synchronization here. This change simplifies the locking logic and aligns the function with other zoned paths, such as __btrfs_add_free_space_zoned(), which only rely on block_group->lock. Since the 'space_info' local variable is no longer used after removing the lock calls, it is also removed. Removing this unnecessary lock reduces contention on the global space_info lock, improving concurrency in the zoned allocation path. Reviewed-by: Boris Burkov <boris@bur.io> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent-tree.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 098e64106d02..c341b97d54e9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4013,9 +4013,8 @@ static int do_allocation_clustered(struct btrfs_block_group *block_group,
* Lock nesting
* ============
*
- * space_info::lock
- * block_group::lock
- * fs_info::treelog_bg_lock
+ * block_group::lock
+ * fs_info::treelog_bg_lock
*/
/*
@@ -4028,7 +4027,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;
@@ -4089,7 +4087,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);
@@ -4191,7 +4188,6 @@ out:
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;
}