Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v2 0/4] btrfs: prepare compression for bs > ps support
@ 2025-09-10  5:18 Qu Wenruo
  2025-09-10  5:18 ` [PATCH v2 1/4] btrfs: prepare compression folio alloc/free for bs > ps cases Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Qu Wenruo @ 2025-09-10  5:18 UTC (permalink / raw)
  To: linux-btrfs

[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(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-15  6:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10  5:18 [PATCH v2 0/4] btrfs: prepare compression for bs > ps support Qu Wenruo
2025-09-10  5:18 ` [PATCH v2 1/4] btrfs: prepare compression folio alloc/free for bs > ps cases Qu Wenruo
2025-09-10  5:18 ` [PATCH v2 2/4] btrfs: prepare zstd to support " Qu Wenruo
2025-09-10  5:18 ` [PATCH v2 3/4] btrfs: prepare lzo " Qu Wenruo
2025-09-10  5:18 ` [PATCH v2 4/4] btrfs: prepare zlib " Qu Wenruo
2025-09-15  6:53 ` [PATCH v2 0/4] btrfs: prepare compression for bs > ps support Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox