Re: [PATCH v3] btrfs: zoned: remove redundant space_info lock and variable in do_allocation_zoned

From: David Sterba

Date: Wed Feb 04 2026 - 09:41:16 EST


On Wed, Jan 14, 2026 at 02:44:50PM +0000, Jiasheng Jiang wrote:
> 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.
>
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@xxxxxxxxx>

Added to for-next, thanks.