diff options
author | Gao Xiang <gaoxiang25@huawei.com> | 2019-10-12 10:43:45 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@aol.com> | 2019-10-13 09:21:13 +0800 |
commit | 561cf9fb45d712e0dd460a03b8cb2b27f658f50b (patch) | |
tree | 3375bd20da36320f0cecab01b68f6403f73659cb /lib/compress.c | |
parent | f8bfa605c31d88a56d6505425cb9f202b088010d (diff) | |
download | erofs-utils-561cf9fb45d712e0dd460a03b8cb2b27f658f50b.tar.gz |
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 <blucerlee@gmail.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Diffstat (limited to 'lib/compress.c')
-rw-r--r-- | lib/compress.c | 14 |
1 files changed, 13 insertions, 1 deletions
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; |