erofs-utils: fix old kernel compatibility for non-lz4 compression
PATCH 1/1 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.
Signed-off-by Gao Xiang <[email protected]>
---
It isn't really clean for the long term, but we can wrap it later after more compression algorithms integrated.
lib/compress.c | 14 +++++++++++++- lib/config.c | 2 -- mkfs/main.c | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-)
lib/compress.c +13 -1
@@ -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;
lib/config.c +0 -2
@@ -19,9 +19,7 @@ void erofs_init_configure(void) cfg.c_dbg_lvl =0 ; cfg.c_version =PACKAGE_VERSION ; cfg.c_dry_run = false; - cfg.c_legacy_compress = false; cfg.c_compr_level_master =-1 ; - sbi.feature_incompat =EROFS_FEATURE_INCOMPAT_LZ4_0PADDING ; cfg.c_force_inodeversion =0 ; cfg.c_unix_timestamp =-1 ; }
mkfs/main.c +3 -0
@@ -215,6 +215,9 @@ int main(int argc, char **argv)erofs_init_configure ();fprintf (stderr,"%s %s\n" ,basename (argv[0 ]), cfg.c_version); + cfg.c_legacy_compress = false; + sbi.feature_incompat =EROFS_FEATURE_INCOMPAT_LZ4_0PADDING ; + err =mkfs_parse_options_cfg (argc, argv);if (err) {if (err == -EINVAL )
Signature · 1 line
2.17.1
Quoted 6 lines
If primary algorithm is not lz4 (e.g. compression off), clear
EROFS_FEATURE_INCOMPAT_LZ4_0PADDINGfor old kernel (upstream kernel <= 5.2.y) compatibility.Signed-off-by Gao Xiang <[email protected]>---
Reviewed-by Li Guifu <[email protected]>
Thanks,