erofs-utils: mkfs: use extended inodes when ctime is set
PATCH v2 1/1 erofs-utils: mkfs: use extended inodes when ctime is set
Currently ctime is effectively ignored because most inodes are compact. If ctime 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.
--- include/erofs/config.h | 1 + lib/config.c | 1 + lib/inode.c | 5 +++++ man/mkfs.erofs.1 | 5 +++++ mkfs/main.c | 5 +++++ 5 files changed, 17 insertions(+)
include/erofs/config.h +1 -0
@@ -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;
lib/config.c +1 -0
@@ -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 ;
lib/inode.c +5 -0
@@ -730,6 +730,11 @@ static bool erofs_should_use_inode_extended(struct erofs_inode *inode)return true;if (inode->i_nlink >USHRT_MAX )return true; +if ((inode->i_ctime != sbi.build_time || + inode->i_ctime_nsec != sbi.build_time_nsec) && + !cfg.c_ignore_mtime) { +return true; + }return false; }
man/mkfs.erofs.1 +5 -0
@@ -109,6 +109,11 @@ Set all file uids to \fIUID\fR. .BI "\-\-force-gid=" GID Set all file gids to \fIGID\fR. .TP +.BI "\-\-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 metadata size. +.TP .B \-\-help Display this help and exit. .TP
mkfs/main.c +5 -0
@@ -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},
@@ -95,6 +96,7 @@ static void usage(void)#endif " --force-uid=# set all file uids to # (# = UID)\n" " --force-gid=# set all file gids to # (# = GID)\n" +" --ignore-mtime use build time and ignore inode modification time\n" " --help display this help and exit\n" " --max-extent-bytes=# set maximum decompressed extent size # in bytes\n" " --quiet quiet execution (do not write anything to standard output.)\n"
@@ -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 );
Signature · 1 line
2.35.1.894.gb6a874cedc-goog
Hi David,
Quoted 4 lines · David Anderson via Linux-erofs
Currently ctime is effectively ignored because most inodes are compact. If ctime was set, and it's different from the build time, then extended inodes should be used instead.
Thanks for your time on this!
I will update this slightly (use mtime rather than ctime), since I will apply the other patches first...
Quoted 82 lines
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.
Signed-off-by David Anderson <[email protected]>--- include/erofs/config.h | 1 + lib/config.c | 1 + lib/inode.c | 5 +++++ man/mkfs.erofs.1 | 5 +++++ mkfs/main.c | 5 +++++ 5 files changed, 17 insertions(+)include/erofs/config.h +1
-0@@ -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;lib/config.c +1
-0@@ -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 ;lib/inode.c +5
-0@@ -730,6 +730,11 @@ static bool erofs_should_use_inode_extended(struct erofs_inode *inode)return true;if (inode->i_nlink >USHRT_MAX )return true; +if ((inode->i_ctime != sbi.build_time || + inode->i_ctime_nsec != sbi.build_time_nsec) && + !cfg.c_ignore_mtime) { +return true; + }return false; }man/mkfs.erofs.1 +5
-0@@ -109,6 +109,11 @@ Set all file uids to \fIUID\fR. .BI "\-\-force-gid=" GID Set all file gids to \fIGID\fR. .TP +.BI "\-\-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 metadata size. +.TP .B \-\-help Display this help and exit. .TPmkfs/main.c +1
-0@@ -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},
mkfs/main.c static void usage(void) · line 99
Quoted 4 lines
mkfs/main.c +1
-0@@ -95,6 +96,7 @@ static void usage(void)#endif " --force-uid=# set all file uids to # (# = UID)\n" " --force-gid=# set all file gids to # (# = GID)\n" +" --ignore-mtime use build time and ignore inode modification time\n"
Use build time and ignore inode modification time if possible
Since if extended inodes are really needed (e.g files more than 4GiB, etc..), extended inodes are still necessary.
Otherwise looks good to me!
(Will apply together with other patches later...)
Thanks,
Gao Xiang
Quoted 15 lines
mkfs/main.c +3
-0" --help display this help and exit\n" " --max-extent-bytes=# set maximum decompressed extent size # in bytes\n" " --quiet quiet execution (do not write anything to standard output.)\n" @@ -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 );Signature · 1 line
2.35.1.894.gb6a874cedc-goog