Skip to content

btrfs: per-fs compression workspace manager

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7btrfs: add an fs_info parameter for compression workspace managerfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/lzo.c +2 more+62 -540 replies
2/7btrfs: add workspace manager initialization for zstdfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/disk-io.c +2 more+93 -102 replies
3/7btrfs: add generic workspace manager initializationfs/btrfs/compression.c+66 -01 reply
4/7btrfs: migrate to use per-fs workspace managerfs/btrfs/compression.c fs/btrfs/zstd.c+48 -410 replies
5/7btrfs: cleanup the per-module workspace managersfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/lzo.c +2 more+1 -1110 replies
6/7btrfs: rename btrfs_compress_op to btrfs_compress_levelsfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/lzo.c +2 more+15 -180 replies
7/7btrfs: reduce workspace buffer space to block sizefs/btrfs/lzo.c fs/btrfs/zlib.c fs/btrfs/zstd.c+20 -110 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid Sterba
SeriesR-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] btrfs: per-fs compression workspace manager

Currently btrfs utilizes the following components at a per-module basis:

- Folios pool
A per-module pool for compressed data.
All folios in the pool are page sized.

- Workspace
A workspace is a compression algorithm specific structure, providing things like extra memory buffer and compression level handling.

- Workspace manager
The workspace manager is managing the above workspaces for each algorithm.

All the folio pool/workspaces are using the fixed PAGE_SIZE buffer size, this is fine for now as even for block size (bs) < page size (ps) cases, a larger buffer size won't cause huge problems except wasting memories.

However if we're going to support bs > ps, this fixed PAGE_SIZE buffer and per-module shared folios pool/workspaces will not work at all.

To address this problem, this series will move the workspace and workspace manager into a per-fs basis, so that different fses (with different block size) can have their own workspaces.

This brings a small memory usage reduce for bs < ps cases. Now zlib/lzo/zstd will only allocate buffer using block size.

This is especially useful for lzo compression algorithm, as lzo is an one-short compression algorithm, it doesn't support multi-shot (aka, swapping input/output buffer halfway) compress/decompress.

Thus btrfs goes per-block compression for LZO, and compressed result will never go larger than a block (or btrfs will just give up). In that case, a 64K page sized buffer will waste 7/8th of the buffer.

This is part 1 of the preparation for btrfs bs > ps support.

Qu Wenruo (7):
btrfs: add an fs_info parameter for compression workspace manager
btrfs: add workspace manager initialization for zstd
btrfs: add generic workspace manager initialization
btrfs: migrate to use per-fs workspace manager
btrfs: cleanup the per-module workspace managers
btrfs: rename btrfs_compress_op to btrfs_compress_levels
btrfs: reduce workspace buffer space to block size

 fs/btrfs/compression.c | 186 ++++++++++++++++++++++++-----------------
 fs/btrfs/compression.h |  49 +++++------
 fs/btrfs/disk-io.c     |   4 +
 fs/btrfs/fs.h          |  13 +++
 fs/btrfs/lzo.c         |  25 +++---
 fs/btrfs/zlib.c        |  16 ++--
 fs/btrfs/zstd.c        | 143 ++++++++++++++++---------------
 7 files changed, 248 insertions(+), 188 deletions(-)
Signature · 1 line
2.50.1