btrfs: prepare compression for bs > ps support
From: | Qu Wenruo <wqu-AT-suse.com> | |
To: | linux-btrfs-AT-vger.kernel.org | |
Subject: | [PATCH 0/4] btrfs: prepare compression for bs > ps support | |
Date: | Tue, 09 Sep 2025 13:08:36 +0930 | |
Message-ID: | <cover.1757388121.git.wqu@suse.com> | |
Archive-link: | Article |
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 | 5 ++-- fs/btrfs/lzo.c | 59 ++++++++++++++++++++++------------------- fs/btrfs/zlib.c | 60 +++++++++++++++++++++++++++--------------- fs/btrfs/zstd.c | 44 +++++++++++++++++-------------- 10 files changed, 157 insertions(+), 84 deletions(-) -- 2.50.1