diff options
| author | Qu Wenruo <[email protected]> | 2025-04-07 08:43:33 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 12:30:45 +0000 |
| commit | 7bf9bfa94684c860479ef125eee4331673f54b5b (patch) | |
| tree | 998b260b58065bf08bbbd52d7e54ada93f520608 /fs/btrfs/compression.h | |
| parent | btrfs: rename __tree_search() to remove double underscore prefix (diff) | |
| download | kernel-7bf9bfa94684c860479ef125eee4331673f54b5b.tar.gz kernel-7bf9bfa94684c860479ef125eee4331673f54b5b.zip | |
btrfs: prepare compression paths for large data folios
All compression algorithms inside btrfs are not supporting large folios
due to the following points:
- btrfs_calc_input_length() is assuming page sized folio
- kmap_local_folio() usages are using offset_in_page()
Prepare them to support large data folios by:
- Add a folio parameter to btrfs_calc_input_length()
And use that folio parameter to calculate the correct length.
Since we're here, also add extra ASSERT()s to make sure the parameter
@cur is inside the folio range.
This affects only zlib and zstd. Lzo compresses at most one block at a
time, thus not affected.
- Use offset_in_folio() to calculate the kmap_local_folio() offset
This affects all 3 algorithms.
Reviewed-by: Filipe Manana <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/compression.h')
| -rw-r--r-- | fs/btrfs/compression.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h index df198623cc08..d34c4341eaf4 100644 --- a/fs/btrfs/compression.h +++ b/fs/btrfs/compression.h @@ -11,7 +11,9 @@ #include <linux/list.h> #include <linux/workqueue.h> #include <linux/wait.h> +#include <linux/pagemap.h> #include "bio.h" +#include "messages.h" struct address_space; struct page; @@ -73,11 +75,14 @@ struct compressed_bio { }; /* @range_end must be exclusive. */ -static inline u32 btrfs_calc_input_length(u64 range_end, u64 cur) +static inline u32 btrfs_calc_input_length(struct folio *folio, u64 range_end, u64 cur) { - u64 page_end = round_down(cur, PAGE_SIZE) + PAGE_SIZE; + const u64 folio_end = folio_pos(folio) + folio_size(folio); - return min(range_end, page_end) - cur; + /* @cur must be inside the folio. */ + ASSERT(folio_pos(folio) <= cur); + ASSERT(cur < folio_end); + return min(range_end, folio_end) - cur; } int __init btrfs_init_compress(void); |
