linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: fix old kernel compatibility for non-lz4 compression
@ 2019-10-12  2:43 Gao Xiang
  2019-10-12 16:28 ` Li Guifu
  0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2019-10-12  2:43 UTC (permalink / raw)
  To: Li Guifu, linux-erofs

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@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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] erofs-utils: fix old kernel compatibility for non-lz4 compression
  2019-10-12  2:43 [PATCH] erofs-utils: fix old kernel compatibility for non-lz4 compression Gao Xiang
@ 2019-10-12 16:28 ` Li Guifu
  0 siblings, 0 replies; 2+ messages in thread
From: Li Guifu @ 2019-10-12 16:28 UTC (permalink / raw)
  To: Gao Xiang, Li Guifu, linux-erofs

> 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@huawei.com>
> ---

Reviewed-by: Li Guifu <blucerlee@gmail.com>

Thanks,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-12 16:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-12  2:43 [PATCH] erofs-utils: fix old kernel compatibility for non-lz4 compression Gao Xiang
2019-10-12 16:28 ` Li Guifu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).