Skip to content

btrfs: prepare compression for bs > ps support

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 1 replyIn review
  2. v14 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Fix a missing callsite inside btrfs_compress_file_range() which only zeros the range inside the first page
The folio_zero_range() of the last compressed folio should cover the full folio, not only the first page.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: prepare compression folio alloc/free for bs > ps casesfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/extent_io.c +6 more+76 -420 replies
2/4btrfs: prepare zstd to support bs > ps casesfs/btrfs/fs.c fs/btrfs/zstd.c+33 -130 replies
3/4btrfs: prepare lzo to support bs > ps casesfs/btrfs/lzo.c+22 -190 replies
4/4btrfs: prepare zlib to support bs > ps casesfs/btrfs/zlib.c+32 -150 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] btrfs: prepare compression for bs > ps support

[CHANGELOG]
v2:
- Fix a missing callsite inside btrfs_compress_file_range() which only zeros the range inside the first page
The folio_zero_range() of the last compressed folio should cover the full folio, not only the first page.

This is the compression part support for bs > ps cases.

The main trick involved is the handling of compr folios, the main changes are:

- Compressed folios now need to follow the minimal order This is the requirement for the recently added btrfs_for_each_block*() helpers, and this keeps our code from handling sub-block sized ranges.

- No cached compression folios for bs > ps cases
Those folios are large and are not sharable between other fses, and most of btrfs will use 4K (until storage with 16K block size got popular).

- Extra rejection of HIGHMEM systems with bs > ps support Unfortunately HIGHMEM large folios need us to map them page by page, this breaks our principle of no sub-block handling.

Considering HIGHMEM is always a pain in the backend and is already planned for deprecation, it's best for everyone to just reject bs > ps btrfses on HIGHMEM systems.

Please still keep in mind that, raid56, scrub, encoded write are not yet supporting bs > ps cases.

For now I have only done basic read/write/balance/offline data check tests on bs > ps cases with all 4 compression algorithms (none, lzo, zlib, zstd), so far so good.

If some one wants to play with the incomplete bs > ps cases, the following simple diff will enable the work:

--- a/fs/btrfs/fs.c
+++ b/fs/btrfs/fs.c
@@ -96,8 +96,7 @@ bool __attribute_const__ btrfs_supported_blocksize(u32 blocksize)

          */
         if (IS_ENABLED(CONFIG_HIGHMEM) && blocksize > PAGE_SIZE)
                 return false;
 -       if (blocksize <= PAGE_SIZE)
 -               return true;
 +       return true;
  #endif
         return false;

}

The remaining features and their road maps are:

- Encoded writes
This should be the most simple part.

- RAID56
Needs to convert the page usage into folio one first.

- Scrub
This relies on some RAID56 interfaces for parity handling. Otherwise pretty like RAID56, we need to convert the page usage to folios first.

Qu Wenruo (4):
btrfs: prepare compression folio alloc/free for bs > ps cases
btrfs: prepare zstd to support bs > ps cases
btrfs: prepare lzo to support bs > ps cases
btrfs: prepare zlib to support bs > ps cases

 fs/btrfs/compression.c | 38 +++++++++++++++++++-------
 fs/btrfs/compression.h |  2 +-
 fs/btrfs/extent_io.c   |  7 +++--
 fs/btrfs/extent_io.h   |  3 ++-
 fs/btrfs/fs.c          | 17 ++++++++++++
 fs/btrfs/fs.h          |  6 +++++
 fs/btrfs/inode.c       | 16 ++++++-----
 fs/btrfs/lzo.c         | 59 ++++++++++++++++++++++-------------------
 fs/btrfs/zlib.c        | 60 +++++++++++++++++++++++++++---------------
 fs/btrfs/zstd.c        | 44 +++++++++++++++++--------------
 10 files changed, 163 insertions(+), 89 deletions(-)
Signature · 1 line
2.50.1