btrfs: pass a space_info argument to btrfs_reserve_metadata_bytes()
authorFilipe Manana <fdmanana@suse.com>
Fri, 8 Sep 2023 17:20:20 +0000 (18:20 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 12 Oct 2023 14:44:05 +0000 (16:44 +0200)
commit03551d651e9d8ff5b310f9038581b2b030daeb87
treebffe565c1936e8c6a1c4837a07bb956fbf1484d9
parent9fb2acc2fe07f15b6cfe94a4bf910d3dfcd6e127
btrfs: pass a space_info argument to btrfs_reserve_metadata_bytes()

We are passing a block reserve argument to btrfs_reserve_metadata_bytes()
which is not really used, all we need is to pass the space_info associated
to the block reserve, we don't change the block reserve at all.

Not only it's pointless to pass the block reserve, it's also confusing as
one might think that the reserved bytes will end up being added to the
passed block reserve, when that's not the case. The pattern for reserving
space and adding it to a block reserve is to first reserve space with
btrfs_reserve_metadata_bytes() and if that succeeds, then add the space to
a block reserve by calling btrfs_block_rsv_add_bytes().

Also the reverse of btrfs_reserve_metadata_bytes(), which is
btrfs_space_info_free_bytes_may_use(), takes a space_info argument and
not a block reserve, so one more reason to pass a space_info and not a
block reserve to btrfs_reserve_metadata_bytes().

So change btrfs_reserve_metadata_bytes() and its callers to pass a
space_info argument instead of a block reserve argument.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-rsv.c
fs/btrfs/delalloc-space.c
fs/btrfs/delayed-ref.c
fs/btrfs/space-info.c
fs/btrfs/space-info.h
fs/btrfs/transaction.c