btrfs: factor out space reservation code from btrfs_buffered_write()
authorQu Wenruo <wqu@suse.com>
Thu, 20 Mar 2025 03:00:59 +0000 (13:30 +1030)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:39 +0000 (14:30 +0200)
commitaf821cba725f31d7305db26cffb07f4d2b96f34f
treedc8d11da9c4104234d2cf64d24ac44b4c5496837
parentafe990fb59c152adef5a80c9168e990e2610b1f7
btrfs: factor out space reservation code from btrfs_buffered_write()

Inside the main loop of btrfs_buffered_write(), we have a complex data
and metadata space reservation code, which tries to reserve space for
a COW write, if failed then fallback to check if we can do a NOCOW
write.

Factor out that part of code into a dedicated helper, reserve_space(),
to make the main loop a little easier to read.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c