erofs-utils: mkfs: Use mtime to seed ctimes
PATCH 1/1 erofs-utils: mkfs: Use mtime to seed ctimes
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.
--- lib/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/inode.c +3 -3
@@ -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;
Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
Hi David,
Quoted 7 lines · David Anderson via Linux-erofs
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
Quoted 29 lines
Change-Id I9cab662398bedc43d6d68ae798912f33360814e3Signed-off-by David Anderson <[email protected]>--- lib/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/inode.c +3
-3@@ -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;Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
Quoted 7 lines · Gao Xiang
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 selectedctime' instead of `mtime'].Should we change what's described in '
Documentation/filesystems/erofs.rst' and even renamei_ctimetoi_mtime?
That's a good idea, I'll repost with a patch to rename to mtime. Initially I figured it was ok, but the "ctime" name would cause problems if EROFS ever stores both timestamps.
Quoted 2 lines
Also should we introduce a new compat feature to indicate that new mkfs records mtime instead?
Will do. Is there anything in the kernel that would need to care about the new flag? (It looks like no but asking just in case.)
Best,
-David
Quoted 6 lines · David Anderson
Quoted 5 lines · Gao Xiang
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 selectedctime' instead of `mtime'].
Quoted 6 lines
Quoted 2 lines
Should we change what's described in '
Documentation/filesystems/erofs.rst' and even renamei_ctimetoi_mtime?That's a good idea, I'll repost with a patch to rename to mtime. Initially I figured it was ok, but the "ctime" name would cause problems if EROFS ever stores both timestamps.
Yeah, I recommend that we could use mtime from now on, but in case that users are confused, we may need add a compatible feature to indicate that.
Quoted 6 lines
Quoted 3 lines
Also should we introduce a new compat feature to indicate that new mkfs records mtime instead?
Will do. Is there anything in the kernel that would need to care about the new flag? (It looks like no but asking just in case.)
No I think, old kernels are still compatible with a new compatible feature. It's just for marking.
Thanks,
Gao Xiang
Quoted 4 lines
Best,
-David
Hi David,
Quoted 10 lines · Gao Xiang
Quoted 9 lines · David Anderson
Quoted 7 lines · Gao Xiang
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 selectedctime' instead of `mtime'].Should we change what's described in '
Documentation/filesystems/erofs.rst' and even renamei_ctimetoi_mtime?
Quoted 6 lines
Quoted 3 lines
That's a good idea, I'll repost with a patch to rename to mtime. Initially I figured it was ok, but the "ctime" name would cause problems if EROFS ever stores both timestamps.
Yeah, I recommend that we could use mtime from now on, but in case that users are confused, we may need add a compatible feature to indicate that.
Would you mind sending a kernel patch to rename them recently if you have some free slot?
We're in 5.17-rc7 cycle.. I think we have to prepare patches for 5.18 now so we can use new timestamp behavior from 5.18..
Thanks,
Gao Xiang
Sorry for not replying sooner, things got very busy - I am working on this now and will hopefully have something tested + uploaded by EOD.
Best,
-David
Quoted 30 lines · Gao Xiang
Hi David,
Quoted 10 lines · Gao Xiang
Quoted 9 lines · David Anderson
Quoted 7 lines · Gao Xiang
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 selectedctime' instead of `mtime'].Should we change what's described in '
Documentation/filesystems/erofs.rst' and even renamei_ctimetoi_mtime?Quoted 6 lines
Quoted 3 lines
That's a good idea, I'll repost with a patch to rename to mtime. Initially I figured it was ok, but the "ctime" name would cause problems if EROFS ever stores both timestamps.
Yeah, I recommend that we could use mtime from now on, but in case that users are confused, we may need add a compatible feature to indicate that.
Would you mind sending a kernel patch to rename them recently if you have some free slot?
We're in 5.17-rc7 cycle.. I think we have to prepare patches for 5.18 now so we can use new timestamp behavior from 5.18..
Thanks,
Gao Xiang
Quoted 2 lines · David Anderson
Sorry for not replying sooner, things got very busy - I am working on this now and will hopefully have something tested + uploaded by EOD.
Yeah, ok. I think it's not urgent to us on the kernel side anyway since it's always compatible with old kernels and mtime == ctime == atime as always, we could also clarify later if it doesn't catch the next merge window.. We could delay it to the next release..
Thanks,
Gao Xiang
Quoted 36 lines
Best,
-David
Quoted 30 lines · Gao Xiang
Hi David,
Quoted 10 lines · Gao Xiang
Quoted 9 lines · David Anderson
Quoted 7 lines · Gao Xiang
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 selectedctime' instead of `mtime'].Should we change what's described in '
Documentation/filesystems/erofs.rst' and even renamei_ctimetoi_mtime?Quoted 6 lines
Quoted 3 lines
That's a good idea, I'll repost with a patch to rename to mtime. Initially I figured it was ok, but the "ctime" name would cause problems if EROFS ever stores both timestamps.
Yeah, I recommend that we could use mtime from now on, but in case that users are confused, we may need add a compatible feature to indicate that.
Would you mind sending a kernel patch to rename them recently if you have some free slot?
We're in 5.17-rc7 cycle.. I think we have to prepare patches for 5.18 now so we can use new timestamp behavior from 5.18..
Thanks,
Gao Xiang