]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: get zone unusable bytes while holding lock at btrfs_reclaim_bgs_work()
authorFilipe Manana <fdmanana@suse.com>
Fri, 21 Feb 2025 16:12:15 +0000 (16:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:41:57 +0000 (14:41 +0200)
commita7f1c5fb7dd90e643a22a446418296dec90ea51b
treec8a78696dcd13e8e0574fa98d1697fb45bdd0dd8
parent4dc7dcb919f3628e0b43432b4ef61f25119c5863
btrfs: get zone unusable bytes while holding lock at btrfs_reclaim_bgs_work()

[ Upstream commit 1283b8c125a83bf7a7dbe90c33d3472b6d7bf612 ]

At btrfs_reclaim_bgs_work(), we are grabbing a block group's zone unusable
bytes while not under the protection of the block group's spinlock, so
this can trigger race reports from KCSAN (or similar tools) since that
field is typically updated while holding the lock, such as at
__btrfs_add_free_space_zoned() for example.

Fix this by grabbing the zone unusable bytes while we are still in the
critical section holding the block group's spinlock, which is right above
where we are currently grabbing it.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/block-group.c