]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: don't reserve space for checksums when writing to nocow files
authorFilipe Manana <fdmanana@suse.com>
Wed, 31 Jan 2024 17:18:04 +0000 (17:18 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 08:51:22 +0000 (09:51 +0100)
commit16d1fe7374df7ed266ccb0f52ae8d52bc39902f0
tree22d81e924e0ed7c3986ad83edfd5e82fa8636916
parentf11f9d8403ead301bf591c9cf8d3bcd7f97cedfc
btrfs: don't reserve space for checksums when writing to nocow files

commit feefe1f49d26bad9d8997096e3a200280fa7b1c5 upstream.

Currently when doing a write to a file we always reserve metadata space
for inserting data checksums. However we don't need to do it if we have
a nodatacow file (-o nodatacow mount option or chattr +C) or if checksums
are disabled (-o nodatasum mount option), as in that case we are only
adding unnecessary pressure to metadata reservations.

For example on x86_64, with the default node size of 16K, a 4K buffered
write into a nodatacow file is reserving 655360 bytes of metadata space,
as it's accounting for checksums. After this change, which stops reserving
space for checksums if we have a nodatacow file or checksums are disabled,
we only need to reserve 393216 bytes of metadata.

CC: stable@vger.kernel.org # 6.1+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/delalloc-space.c