[PATCH] erofs-utils: mkfs: Use mtime to seed ctimes

Gao Xiang hsiangkao at linux.alibaba.com
Tue Mar 1 16:27:52 AEDT 2022


Hi David,

On Tue, Mar 01, 2022 at 04:11:39AM +0000, David Anderson via Linux-erofs wrote:
> Currently mkfs.erofs picks up whatever the system time happened to be
> when the input file structure was created. Since there's no (easy) way for
> userspace to control ctime, there's no way to control the per-file ctime
> that mkfs.erofs uses.
> 
> Switching to mtime allows this tuning, which is important when the
> timestamp of files is used to detect staleness.

Yeah, I agree I should think more when I planned to store `ctime' at the
first time [my original thought was to keep metadata time (including
uid, gid, etc..), so I selected `ctime' instead of `mtime'].

Should we change what's described in 'Documentation/filesystems/erofs.rst'
and even rename i_ctime to i_mtime?

Also should we introduce a new compat feature to indicate that new mkfs
records mtime instead?

Thanks,
Gao Xiang

> 
> Change-Id: I9cab662398bedc43d6d68ae798912f33360814e3
> Signed-off-by: David Anderson <dvander at google.com>
> ---
>  lib/inode.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index 461c797..f0a71a8 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -806,12 +806,12 @@ static int erofs_fill_inode(struct erofs_inode *inode,
>  	inode->i_mode = st->st_mode;
>  	inode->i_uid = cfg.c_uid == -1 ? st->st_uid : cfg.c_uid;
>  	inode->i_gid = cfg.c_gid == -1 ? st->st_gid : cfg.c_gid;
> -	inode->i_ctime = st->st_ctime;
> -	inode->i_ctime_nsec = ST_CTIM_NSEC(st);
> +	inode->i_ctime = st->st_mtime;
> +	inode->i_ctime_nsec = ST_MTIM_NSEC(st);
>  
>  	switch (cfg.c_timeinherit) {
>  	case TIMESTAMP_CLAMPING:
> -		if (st->st_ctime < sbi.build_time)
> +		if (st->st_mtime < sbi.build_time)
>  			break;
>  	case TIMESTAMP_FIXED:
>  		inode->i_ctime = sbi.build_time;
> -- 
> 2.35.1.574.g5d30c73bfb-goog


More information about the Linux-erofs mailing list