]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: reduce compression workspace buffer space to block size
authorQu Wenruo <wqu@suse.com>
Thu, 14 Aug 2025 01:14:48 +0000 (10:44 +0930)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:16 +0000 (08:49 +0200)
commit74e8f002b772686408d62e420d9f70a4bcb1c2c4
tree86e44fee1637e9495949f50bda0e1ce3cc4f510e
parent0d0b80929eff93e7e0323060899d04905b8e6de9
btrfs: reduce compression workspace buffer space to block size

Currently the compression workspace buffer size is always based on
PAGE_SIZE, but btrfs has support subpage sized block size for some time.

This means for one-shot compression algorithm like lzo, we're wasting
quite some memory if the block size is smaller than page size, as the
LZO only works on one block (thus one-shot).

On 64K page sized systems with 4K block size, it means we only need at
most 8K buffer space for lzo, but in reality we're allocating 64K
buffer.

So to reduce the memory usage, change all workspace buffer to base its
size based on block size other than page size.

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/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c