]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: shorten critical section in btrfs_preempt_reclaim_metadata_space()
authorFilipe Manana <fdmanana@suse.com>
Fri, 17 Oct 2025 16:07:22 +0000 (17:07 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:09:46 +0000 (22:09 +0100)
commit4ddb077378aa84d0872fdfce85e7a82fd805ee86
tree7c8b9df591c9729699b0b85035d35852b76b2991
parent8ab2b8bdbecaaf1b01adc5cfc13534a04917515d
btrfs: shorten critical section in btrfs_preempt_reclaim_metadata_space()

We are doing a lot of small calculations and assignments while holding the
space_info's spinlock, which is a heavily used lock for space reservation
and flushing. There's no point in holding the lock for so long when all we
want is to call need_preemptive_reclaim() and get a consistent value for a
couple of counters from the space_info. Instead, grab the counters into
local variables, release the lock and then use the local variables.

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