From 561cf9fb45d712e0dd460a03b8cb2b27f658f50b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 12 Oct 2019 10:43:45 +0800 Subject: erofs-utils: fix old kernel compatibility for non-lz4 compression If primary algorithm is not lz4 (e.g. compression off), clear EROFS_FEATURE_INCOMPAT_LZ4_0PADDING for old kernel (upstream kernel <= 5.2.y) compatibility. Link: https://lore.kernel.org/r/20191012024345.181737-1-gaoxiang25@huawei.com Reviewed-by: Li Guifu Signed-off-by: Gao Xiang --- lib/compress.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/compress.c') diff --git a/lib/compress.c b/lib/compress.c index 7f65e5e..99fd527 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -504,9 +504,21 @@ int z_erofs_compress_init(void) /* initialize for primary compression algorithm */ int ret = erofs_compressor_init(&compresshandle, cfg.c_compr_alg_master); - if (ret || !cfg.c_compr_alg_master) + + if (ret) return ret; + /* + * if primary algorithm is not lz4* (e.g. compression off), + * clear LZ4_0PADDING feature for old kernel compatibility. + */ + if (!cfg.c_compr_alg_master || + strncmp(cfg.c_compr_alg_master, "lz4", 3)) + sbi.feature_incompat &= ~EROFS_FEATURE_INCOMPAT_LZ4_0PADDING; + + if (!cfg.c_compr_alg_master) + return 0; + compressionlevel = cfg.c_compr_level_master < 0 ? compresshandle.alg->default_level : cfg.c_compr_level_master; -- cgit v1.2.3