[PATCH 2/2] erofs-utils: lib: migrate `c_ignore_mtime`

Gao Xiang hsiangkao at linux.alibaba.com
Tue Sep 9 19:40:13 AEST 2025


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

diff --git a/include/erofs/config.h b/include/erofs/config.h
index 6554ad2..67f5aa3 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -53,7 +53,6 @@ struct erofs_configure {
 	bool c_all_fragments;
 	bool c_dedupe;
 	char c_fragdedupe;
-	bool c_ignore_mtime;
 	bool c_showprogress;
 	bool c_extra_ea_name_prefixes;
 	bool c_xattr_name_filter;
diff --git a/include/erofs/importer.h b/include/erofs/importer.h
index 85e3a50..a5a4c8c 100644
--- a/include/erofs/importer.h
+++ b/include/erofs/importer.h
@@ -26,6 +26,7 @@ struct erofs_importer_params {
 	u32 gid_offset;
 	u32 fsalignblks;
 	char force_inodeversion;
+	bool ignore_mtime;
 	bool no_datainline;
 	bool hard_dereference;
 	bool ovlfs_strip;
diff --git a/lib/config.c b/lib/config.c
index 28bfc2f..b1d076d 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -29,7 +29,6 @@ void erofs_init_configure(void)
 	cfg.c_dbg_lvl  = EROFS_WARN;
 	cfg.c_version  = PACKAGE_VERSION;
 	cfg.c_dry_run  = false;
-	cfg.c_ignore_mtime = false;
 	cfg.c_inline_xattr_tolerance = 2;
 	cfg.c_unix_timestamp = -1;
 	cfg.c_max_decompressed_extent_bytes = -1;
diff --git a/lib/inode.c b/lib/inode.c
index 0bb82f8..75a0b4d 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -717,7 +717,7 @@ int erofs_iflush(struct erofs_inode *inode)
 	    inode->u.i_blocks > UINT32_MAX) {
 		nb.blocks_hi = cpu_to_le16(inode->u.i_blocks >> 32);
 	} else if (inode->datalayout != EROFS_INODE_CHUNK_BASED &&
-		 inode->u.i_blkaddr > UINT32_MAX) {
+		   inode->u.i_blkaddr > UINT32_MAX) {
 		nb.startblk_hi = cpu_to_le16(inode->u.i_blkaddr >> 32);
 		if (inode->u.i_blkaddr == EROFS_NULL_ADDR) {
 			nlink_1 = false;
@@ -744,8 +744,7 @@ int erofs_iflush(struct erofs_inode *inode)
 
 		u.dic.i_uid = cpu_to_le16((u16)inode->i_uid);
 		u.dic.i_gid = cpu_to_le16((u16)inode->i_gid);
-		if (!cfg.c_ignore_mtime)
-			u.dic.i_mtime = cpu_to_le64(inode->i_mtime - sbi->epoch);
+		u.dic.i_mtime = cpu_to_le64(inode->i_mtime - sbi->epoch);
 		u.dic.i_u = u1;
 
 		if (nlink_1) {
@@ -1076,7 +1075,9 @@ out:
 static bool erofs_should_use_inode_extended(struct erofs_importer *im,
 				struct erofs_inode *inode, const char *path)
 {
-	if (im->params->force_inodeversion == EROFS_FORCE_INODE_EXTENDED)
+	const struct erofs_importer_params *params = im->params;
+
+	if (params->force_inodeversion == EROFS_FORCE_INODE_EXTENDED)
 		return true;
 	if (inode->i_size > UINT_MAX)
 		return true;
@@ -1088,10 +1089,13 @@ static bool erofs_should_use_inode_extended(struct erofs_importer *im,
 		return true;
 	if (inode->i_nlink > USHRT_MAX)
 		return true;
-	if (!erofs_is_special_identifier(path) && !cfg.c_ignore_mtime &&
+	if (!erofs_is_special_identifier(path) &&
 	    !erofs_sb_has_48bit(inode->sbi) &&
-	    inode->i_mtime != inode->sbi->epoch)
-		return true;
+	    inode->i_mtime != inode->sbi->epoch) {
+		if (!params->ignore_mtime)
+			return true;
+		inode->i_mtime = inode->sbi->epoch;
+	}
 	return false;
 }
 
diff --git a/mkfs/main.c b/mkfs/main.c
index 4f52656..1b5cb2b 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -463,7 +463,7 @@ static int parse_extended_opts(struct erofs_importer_params *params,
 			if (vallen)
 				return -EINVAL;
 			params->force_inodeversion = EROFS_FORCE_INODE_COMPACT;
-			cfg.c_ignore_mtime = true;
+			params->ignore_mtime = true;
 		} else if (MATCH_EXTENTED_OPT("force-inode-extended", token, keylen)) {
 			if (vallen)
 				return -EINVAL;
@@ -1170,10 +1170,10 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 			cfg.c_blobdev_path = optarg;
 			break;
 		case 14:
-			cfg.c_ignore_mtime = true;
+			params->ignore_mtime = true;
 			break;
 		case 15:
-			cfg.c_ignore_mtime = false;
+			params->ignore_mtime = false;
 			break;
 		case 16:
 			errno = 0;
-- 
2.43.5



More information about the Linux-erofs mailing list