btrfs: convert count_max_extents() to use fs_info->max_extent_size
authorNaohiro Aota <naohiro.aota@wdc.com>
Mon, 22 Aug 2022 06:07:04 +0000 (15:07 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2022 15:16:34 +0000 (17:16 +0200)
commit057238cdce45c6764df05315646851b7a58b6e90
tree45c632c5ea4978b20571a8ae5a094c8067b5a3f3
parent1aa262c1d056551dd1246115af8b7e351184deae
btrfs: convert count_max_extents() to use fs_info->max_extent_size

commit 7d7672bc5d1038c745716c397d892d21e29de71c upstream

If count_max_extents() uses BTRFS_MAX_EXTENT_SIZE to calculate the number
of extents needed, btrfs release the metadata reservation too much on its
way to write out the data.

Now that BTRFS_MAX_EXTENT_SIZE is replaced with fs_info->max_extent_size,
convert count_max_extents() to use it instead, and fix the calculation of
the metadata reservation.

CC: stable@vger.kernel.org # 5.12+
Fixes: d8e3fb106f39 ("btrfs: zoned: use ZONE_APPEND write for zoned mode")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ctree.h
fs/btrfs/delalloc-space.c
fs/btrfs/inode.c