diff options
author | David Anderson <dvander@google.com> | 2022-03-18 05:25:36 +0000 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2022-03-23 12:20:29 -0700 |
commit | 59fe8bb5df743ad4bae13b364dcfc009641dc5fa (patch) | |
tree | 91ab5512d3fe290c61df50ac2cdb5ac5db15ce34 | |
parent | d89215b66a420aa2e60b0d4a4d300cfc3ff5815d (diff) | |
download | erofs-utils-59fe8bb5df743ad4bae13b364dcfc009641dc5fa.tar.gz |
erofs-utils: mkfs: use extended inodes when ctime is set
Currently mtime is effectively ignored because most inodes are compact.
If mtime was set, and it's different from the build time, then extended
inodes should be used instead.
To guarantee that timestamps do not cause extended inodes, a fixed
timestamp should be used (-T). Additionally, a new --ignore-mtime option
has been added to preserve the old behavior.
Link: https://lore.kernel.org/r/20220318052536.1358747-1-dvander@google.com
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: David Anderson <dvander@google.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Change-Id: I47373995abda0d223c34af176c0e82233dbdf90f
-rw-r--r-- | include/erofs/config.h | 1 | ||||
-rw-r--r-- | lib/config.c | 1 | ||||
-rw-r--r-- | lib/inode.c | 4 | ||||
-rw-r--r-- | man/mkfs.erofs.1 | 5 | ||||
-rw-r--r-- | mkfs/main.c | 5 |
5 files changed, 16 insertions, 0 deletions
diff --git a/include/erofs/config.h b/include/erofs/config.h index cb064b6..0a1b18b 100644 --- a/include/erofs/config.h +++ b/include/erofs/config.h @@ -43,6 +43,7 @@ struct erofs_configure { char c_timeinherit; char c_chunkbits; bool c_noinline_data; + bool c_ignore_mtime; #ifdef HAVE_LIBSELINUX struct selabel_handle *sehnd; diff --git a/lib/config.c b/lib/config.c index f1c8edf..cc15e57 100644 --- a/lib/config.c +++ b/lib/config.c @@ -20,6 +20,7 @@ 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_compr_level_master = -1; cfg.c_force_inodeversion = 0; cfg.c_inline_xattr_tolerance = 2; diff --git a/lib/inode.c b/lib/inode.c index c9fdda1..77ea8bf 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -730,6 +730,10 @@ static bool erofs_should_use_inode_extended(struct erofs_inode *inode) return true; if (inode->i_nlink > USHRT_MAX) return true; + if ((inode->i_mtime != sbi.build_time || + inode->i_mtime_nsec != sbi.build_time_nsec) && + !cfg.c_ignore_mtime) + return true; return false; } diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1 index 9c7788e..d61e33e 100644 --- a/man/mkfs.erofs.1 +++ b/man/mkfs.erofs.1 @@ -112,6 +112,11 @@ Set all file gids to \fIGID\fR. .B \-\-help Display this help and exit. .TP +.B "\-\-ignore-mtime" +File modification time is ignored whenever it would cause \fBmkfs.erofs\fR to +use extended inodes over compact inodes. When not using a fixed timestamp, this +can reduce total metadata size. +.TP .BI "\-\-max-extent-bytes " # Specify maximum decompressed extent size # in bytes. .SH AUTHOR diff --git a/mkfs/main.c b/mkfs/main.c index 9f35179..b62a8aa 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -49,6 +49,7 @@ static struct option long_options[] = { {"chunksize", required_argument, NULL, 11}, {"quiet", no_argument, 0, 12}, {"blobdev", required_argument, NULL, 13}, + {"ignore-mtime", no_argument, NULL, 14}, #ifdef WITH_ANDROID {"mount-point", required_argument, NULL, 512}, {"product-out", required_argument, NULL, 513}, @@ -96,6 +97,7 @@ static void usage(void) " --force-uid=# set all file uids to # (# = UID)\n" " --force-gid=# set all file gids to # (# = GID)\n" " --help display this help and exit\n" + " --ignore-mtime use build time instead of strict per-file modification time\n" " --max-extent-bytes=# set maximum decompressed extent size # in bytes\n" " --quiet quiet execution (do not write anything to standard output.)\n" #ifndef NDEBUG @@ -366,6 +368,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) case 13: cfg.c_blobdev_path = optarg; break; + case 14: + cfg.c_ignore_mtime = true; + break; case 1: usage(); exit(0); |