]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: add data_race() in btrfs_account_ro_block_groups_free_space()
authorFilipe Manana <fdmanana@suse.com>
Thu, 23 Oct 2025 12:24:22 +0000 (13:24 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:16:27 +0000 (22:16 +0100)
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 <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>
fs/btrfs/space-info.c

index edeb46f1aa33c96ac7ccee266be0fab442966508..be58f702cc61c65b04e24ecdffcf9138db52b1b7 100644 (file)
@@ -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);