]> Gentwo Git Trees - linux/.git/commit
btrfs: avoid used space computation when trying to grant tickets
authorFilipe Manana <fdmanana@suse.com>
Fri, 17 Oct 2025 14:47:59 +0000 (15:47 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:07:26 +0000 (22:07 +0100)
commita5f8f64aa3377b470945252f926e2cbb5a931c11
tree98acaad73551525809e6372bc863579595b80daa
parent563ef2befb55a75ba13b66d9714d50b848de8aae
btrfs: avoid used space computation when trying to grant tickets

In btrfs_try_granting_tickets(), we call btrfs_can_overcommit() and that
calls btrfs_space_info_used(). But we already keep track, in the 'used'
local variable, of the used space in the space_info, so we are just
repeating the same computation and doing an extra function call while we
are holding the space_info's spinlock, which is heavily used by the space
reservation and flushing code.

So add a local variant of btrfs_can_overcommit() that takes in the used
space as an argument and therefore does not call btrfs_space_info_used(),
and use it in btrfs_try_granting_tickets().

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