[PATCH 1/5] erofs-utils: lib: migrate and split `c_legacy_compress`

Gao Xiang hsiangkao at linux.alibaba.com
Tue Sep 30 16:38:43 AEST 2025


Split it into `no_zcompact` and `no_lz4_0padding` meta-switches.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 include/erofs/config.h   | 1 -
 include/erofs/importer.h | 2 ++
 lib/compress.c           | 5 +++--
 mkfs/main.c              | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index 3b1438f..153315b 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -39,7 +39,6 @@ struct erofs_configure {
 	const char *c_version;
 	int c_dbg_lvl;
 	bool c_dry_run;
-	bool c_legacy_compress;
 	char c_timeinherit;
 	char c_chunkbits;
 	bool c_showprogress;
diff --git a/include/erofs/importer.h b/include/erofs/importer.h
index 3153732..dbb87be 100644
--- a/include/erofs/importer.h
+++ b/include/erofs/importer.h
@@ -41,6 +41,8 @@ struct erofs_importer_params {
 	bool hard_dereference;
 	bool ovlfs_strip;
 	bool dot_omitted;
+	bool no_zcompact;
+	bool no_lz4_0padding;
 	bool ztailpacking;
 	bool dedupe;
 	bool fragments;
diff --git a/lib/compress.c b/lib/compress.c
index f879d3e..b7ca3ad 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1144,6 +1144,7 @@ static void *z_erofs_write_extents(struct z_erofs_compress_ictx *ctx)
 
 static void *z_erofs_write_indexes(struct z_erofs_compress_ictx *ctx)
 {
+	const struct erofs_importer_params *params = ctx->im->params;
 	struct erofs_inode *inode = ctx->inode;
 	struct erofs_sb_info *sbi = inode->sbi;
 	struct z_erofs_extent_item *ei, *n;
@@ -1165,7 +1166,7 @@ static void *z_erofs_write_indexes(struct z_erofs_compress_ictx *ctx)
 	 */
 	if (inode->fragment_size && inode->fragmentoff >> 32) {
 		inode->datalayout = EROFS_INODE_COMPRESSED_FULL;
-	} else if (!cfg.c_legacy_compress && !ctx->dedupe &&
+	} else if (!params->no_zcompact && !ctx->dedupe &&
 		   inode->z_lclusterbits <= 14) {
 		if (inode->z_lclusterbits <= 12)
 			inode->z_advise |= Z_EROFS_ADVISE_COMPACTED_2B;
@@ -2120,7 +2121,7 @@ int z_erofs_compress_init(struct erofs_importer *im)
 	} else {
 		sbi->available_compr_algs = available_compr_algs;
 
-		if (!cfg.c_legacy_compress)
+		if (!params->no_lz4_0padding)
 			erofs_sb_set_lz4_0padding(sbi);
 		if (available_compr_algs & ~(1 << Z_EROFS_COMPRESSION_LZ4))
 			erofs_sb_set_compr_cfgs(sbi);
diff --git a/mkfs/main.c b/mkfs/main.c
index f3cf24e..25f28ee 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -312,7 +312,8 @@ static int erofs_mkfs_feat_set_legacy_compress(struct erofs_importer_params *par
 	if (vallen)
 		return -EINVAL;
 	/* disable compacted indexes and 0padding */
-	cfg.c_legacy_compress = en;
+	params->no_zcompact = true;
+	params->no_lz4_0padding = true;
 	return 0;
 }
 
@@ -1501,7 +1502,6 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 static void erofs_mkfs_default_options(struct erofs_importer_params *params)
 {
 	cfg.c_showprogress = true;
-	cfg.c_legacy_compress = false;
 	cfg.c_xattr_name_filter = true;
 #ifdef EROFS_MT_ENABLED
 	cfg.c_mt_workers = erofs_get_available_processors();
-- 
2.43.5



More information about the Linux-erofs mailing list