]> git.ipfire.org Git - thirdparty/linux.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)
committerDavid Sterba <dsterba@suse.com>
Tue, 13 Feb 2024 17:36:35 +0000 (18:36 +0100)
commitfeefe1f49d26bad9d8997096e3a200280fa7b1c5
treebeebaee9d360b2b4f399dae22c2f887c071616f0
parent12c5128f101bfa47a08e4c0e1a75cfa2d0872bcd
btrfs: don't reserve space for checksums when writing to nocow files

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>
fs/btrfs/delalloc-space.c