[PATCH v3 05/18] f2fs: size the lz4hc context by the compression level
From: Michal Wilczynski
Date: Wed Dec 02 2026 - 12:34:43 EST
lz4_init_compress_ctx() allocates LZ4HC_MEM_COMPRESS bytes for any
non-zero lz4hc level. With the vendored LZ4 library that follows in this
series, levels 10 and up need a ~64K workspace after the state, so
allocate lz4hc_mem_compress(level) instead. It is LZ4HC_MEM_COMPRESS at
every level until then.
The context is sized by the level as it is already sized by lz4 vs
lz4hc: F2FS_IOC_SET_COMPRESS_OPTION, the only thing that changes an
inode's level, refuses an inode with dirty pages or blocks.
Signed-off-by: Michal Wilczynski <m.wilczynski@xxxxxxxxxxx>
---
fs/f2fs/compress.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index d0e989254ffe4b86bc20194d9e0f8137a3efb4b8..39c1bfb3619a0732306b6b30e3063121e8162b21 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -252,7 +252,7 @@ static int lz4_init_compress_ctx(struct compress_ctx *cc)
#ifdef CONFIG_F2FS_FS_LZ4HC
if (F2FS_I(cc->inode)->i_compress_level)
- size = LZ4HC_MEM_COMPRESS;
+ size = lz4hc_mem_compress(F2FS_I(cc->inode)->i_compress_level);
#endif
cc->private = f2fs_vmalloc(F2FS_I_SB(cc->inode), size);
--
2.34.1