Skip to content

Commit 08ef566

Browse files
Jiasheng Jiangkdave
authored andcommitted
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 <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Naohiro Aota <[email protected]> Signed-off-by: Jiasheng Jiang <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 6141abb commit 08ef566

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

fs/btrfs/extent-tree.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,9 +4013,8 @@ static int do_allocation_clustered(struct btrfs_block_group *block_group,
40134013
* Lock nesting
40144014
* ============
40154015
*
4016-
* space_info::lock
4017-
* block_group::lock
4018-
* fs_info::treelog_bg_lock
4016+
* block_group::lock
4017+
* fs_info::treelog_bg_lock
40194018
*/
40204019

40214020
/*
@@ -4028,7 +4027,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
40284027
struct btrfs_block_group **bg_ret)
40294028
{
40304029
struct btrfs_fs_info *fs_info = block_group->fs_info;
4031-
struct btrfs_space_info *space_info = block_group->space_info;
40324030
struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
40334031
u64 start = block_group->start;
40344032
u64 num_bytes = ffe_ctl->num_bytes;
@@ -4089,7 +4087,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
40894087
*/
40904088
}
40914089

4092-
spin_lock(&space_info->lock);
40934090
spin_lock(&block_group->lock);
40944091
spin_lock(&fs_info->treelog_bg_lock);
40954092
spin_lock(&fs_info->relocation_bg_lock);
@@ -4191,7 +4188,6 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
41914188
spin_unlock(&fs_info->relocation_bg_lock);
41924189
spin_unlock(&fs_info->treelog_bg_lock);
41934190
spin_unlock(&block_group->lock);
4194-
spin_unlock(&space_info->lock);
41954191
return ret;
41964192
}
41974193

0 commit comments

Comments
 (0)