Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

include/linux/lz4.h: add some missing macros

Currently, LZ4_DISTANCE_MAX and LZ4_DECOMPRESS_INPLACE_MARGIN are
defined in the erofs subsystem for LZ4 in-place decompression, which is
somewhat unsuitable since they should belong to the LZ4 itself and
may change with future LZ4 codebase updates.

Move them to include/linux/lz4.h to match the upstream LZ4 library [1].
No logic changes.

[1] https://github.com/lz4/lz4/blob/v1.10.0/lib/lz4.h#L670

Link: https://lkml.kernel.org/r/20250114130454.1191150-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Yann Collet <yann.collet.73@gmail.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <zbestahu@gmail.com>
Cc; Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: Sandeep Dhavale <dhavale@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Gao Xiang and committed by
Andrew Morton
f0ef073e 13fd5cf3

+8 -12
-7
fs/erofs/decompressor.c
··· 7 7 #include "compress.h" 8 8 #include <linux/lz4.h> 9 9 10 - #ifndef LZ4_DISTANCE_MAX /* history window size */ 11 - #define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ 12 - #endif 13 - 14 10 #define LZ4_MAX_DISTANCE_PAGES (DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + 1) 15 - #ifndef LZ4_DECOMPRESS_INPLACE_MARGIN 16 - #define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize) (((srcsize) >> 8) + 32) 17 - #endif 18 11 19 12 struct z_erofs_lz4_decompress_ctx { 20 13 struct z_erofs_decompress_req *rq;
+6
include/linux/lz4.h
··· 645 645 int LZ4_decompress_fast_usingDict(const char *source, char *dest, 646 646 int originalSize, const char *dictStart, int dictSize); 647 647 648 + #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32) 649 + 650 + #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */ 651 + #define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ 652 + #endif 653 + 648 654 #endif
-1
lib/lz4/lz4_compress.c
··· 33 33 /*-************************************ 34 34 * Dependencies 35 35 **************************************/ 36 - #include <linux/lz4.h> 37 36 #include "lz4defs.h" 38 37 #include <linux/module.h> 39 38 #include <linux/kernel.h>
-1
lib/lz4/lz4_decompress.c
··· 33 33 /*-************************************ 34 34 * Dependencies 35 35 **************************************/ 36 - #include <linux/lz4.h> 37 36 #include "lz4defs.h" 38 37 #include <linux/init.h> 39 38 #include <linux/module.h>
+2 -2
lib/lz4/lz4defs.h
··· 39 39 40 40 #include <linux/bitops.h> 41 41 #include <linux/string.h> /* memset, memcpy */ 42 + #include <linux/lz4.h> 42 43 43 44 #define FORCE_INLINE __always_inline 44 45 ··· 93 92 #define MB (1 << 20) 94 93 #define GB (1U << 30) 95 94 96 - #define MAXD_LOG 16 97 - #define MAX_DISTANCE ((1 << MAXD_LOG) - 1) 95 + #define MAX_DISTANCE LZ4_DISTANCE_MAX 98 96 #define STEPSIZE sizeof(size_t) 99 97 100 98 #define ML_BITS 4
-1
lib/lz4/lz4hc_compress.c
··· 34 34 /*-************************************ 35 35 * Dependencies 36 36 **************************************/ 37 - #include <linux/lz4.h> 38 37 #include "lz4defs.h" 39 38 #include <linux/module.h> 40 39 #include <linux/kernel.h>