[PATCH] erofs-utils: fix old kernel compatibility for non-lz4 compression
Gao Xiang
gaoxiang25 at huawei.com
Sat Oct 12 13:43:45 AEDT 2019
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 <gaoxiang25 at huawei.com>
---
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(-)
diff --git a/lib/compress.c b/lib/compress.c
index 7f65e5e26938..fdf093b69891 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;
diff --git a/lib/config.c b/lib/config.c
index 4cddc252b46a..46625d7c61c7 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -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;
}
diff --git a/mkfs/main.c b/mkfs/main.c
index 1df69d74b633..536b784eec01 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -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)
--
2.17.1
More information about the Linux-erofs
mailing list