aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.h
diff options
context:
space:
mode:
authorQu Wenruo <[email protected]>2024-05-29 07:33:47 +0000
committerDavid Sterba <[email protected]>2024-09-10 14:51:20 +0000
commitfd1e75d0105d2289e24b6d63cee49e6f7952c8bf (patch)
tree7d4844b1731f52569a694ca5cc5cf795ca6f95a4 /fs/btrfs/compression.h
parentbtrfs: merge btrfs_orig_bbio_end_io() into btrfs_bio_end_io() (diff)
downloadkernel-fd1e75d0105d2289e24b6d63cee49e6f7952c8bf.tar.gz
kernel-fd1e75d0105d2289e24b6d63cee49e6f7952c8bf.zip
btrfs: make compression path to be subpage compatible
Currently btrfs compression path is not really subpage compatible, every thing is still done in page unit. That's fine for regular sector size and subpage routine. As even for subpage routine compression is only enabled if the whole range is page aligned, so reading the page cache in page unit is totally fine. However in preparation for the future subpage perfect compression support, we need to change the compression routine to properly handle a subpage range. This patch would prepare both zlib and zstd to only read the subpage range for compression. Lzo is already doing subpage aware read, as lzo's on-disk format is already sectorsize dependent. 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.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index cfdc64319186..5d01f092ae13 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -82,6 +82,14 @@ static inline unsigned int btrfs_compress_level(unsigned int type_level)
return ((type_level & 0xF0) >> 4);
}
+/* @range_end must be exclusive. */
+static inline u32 btrfs_calc_input_length(u64 range_end, u64 cur)
+{
+ u64 page_end = round_down(cur, PAGE_SIZE) + PAGE_SIZE;
+
+ return min(range_end, page_end) - cur;
+}
+
int __init btrfs_init_compress(void);
void __cold btrfs_exit_compress(void);