On Tue, 6 May 2014, Vadim Zhukov wrote:
> This fixes a bug with mtime not updated after file creation on ext2+
> file systems. Try it yourself:
>
> # mount -t ext2fs /dev/sd0o /mnt
> # cp /tmp/qq /mnt
> # ls -l /mnt/qq
> -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq
> # touch /mnt/qq
> -rw-r--r-- 1 root wheel 10 May 6 14:36 qq
>
> This probably does more than needed - I suspect that sometimes
> the updated mtime could be already there, but I don't see any real
> downside and it makes EX2FS_ITIMES() look more similar to
> ufs_itimies(). Opinions? Okays?
As the person who broke this (sorry!), I think the diff should go a couple
steps further and restore the IN_ACCESS handling too and mirror
ufs_itimes() by bumping i_modrev on ctime change.
Philip
Index: ufs/ufs/inode.h
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/inode.h,v
retrieving revision 1.44
diff -u -p -r1.44 inode.h
--- ufs/ufs/inode.h 14 Apr 2014 22:25:40 -0000 1.44
+++ ufs/ufs/inode.h 6 May 2014 15:31:24 -0000
@@ -316,8 +316,14 @@ struct indir {
#define EXT2FS_ITIMES(ip) do {
\
if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
(ip)->i_flag |= IN_MODIFIED; \
- if ((ip)->i_flag & IN_CHANGE) \
+ if ((ip)->i_flag & IN_ACCESS) \
+ (ip)->i_e2fs_atime = time_second; \
+ if ((ip)->i_flag & IN_UPDATE) \
+ (ip)->i_e2fs_mtime = time_second; \
+ if ((ip)->i_flag & IN_CHANGE) { \
(ip)->i_e2fs_ctime = time_second; \
+ (ip)->i_modrev++; \
+ } \
(ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
} \
} while (0)