From: Filipe Manana Date: Thu, 23 Oct 2025 12:24:22 +0000 (+0100) Subject: btrfs: add data_race() in btrfs_account_ro_block_groups_free_space() X-Git-Tag: v6.19-rc1~167^2~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdf8a566eeef0c28a082dcdfb5d91e964029d6c3;p=thirdparty%2Fkernel%2Flinux.git btrfs: add data_race() in btrfs_account_ro_block_groups_free_space() Surround the intentional empty list check with the data_race() annotation so that tools like KCSAN don't report a data race. The race is intentional as it's harmless and we want to avoid lock contention of the space_info since its lock is heavily used (space reservation, space flushing, extent allocation and deallocation, etc). Reviewed-by: Johannes Thumshirn Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index edeb46f1aa33c..be58f702cc61c 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -1948,7 +1948,7 @@ u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo) int factor; /* It's df, we don't care if it's racy */ - if (list_empty(&sinfo->ro_bgs)) + if (data_race(list_empty(&sinfo->ro_bgs))) return 0; spin_lock(&sinfo->lock);