Update ctime when atime or birthtime are updated.

Cleanup setting of ctime/mtime/birthtime: do not set IN_ACCESS or
IN_UPDATE, then clear them with ufs_itimes(), making transient
(possibly inconsistent) change to the times, and then copy
user-supplied times into the inode.  Instead, directly clear IN_ACCESS
or IN_UPDATE when user supplied the time, and copy the value into the
inode.

Minor inconsistency left is that the inode ctime is updated even when
birthtime update attempt is performed on a UFS1 volume.

Submitted by:	bde
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2015-12-07 12:09:04 +00:00
parent 74540a3183
commit dc15d94fd9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291936

View File

@ -639,19 +639,14 @@ ufs_setattr(ap)
error = vn_utimes_perm(vp, vap, cred, td);
if (error != 0)
return (error);
if (vap->va_atime.tv_sec != VNOVAL)
ip->i_flag |= IN_ACCESS;
if (vap->va_mtime.tv_sec != VNOVAL)
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (vap->va_birthtime.tv_sec != VNOVAL &&
ip->i_ump->um_fstype == UFS2)
ip->i_flag |= IN_MODIFIED;
ufs_itimes(vp);
ip->i_flag |= IN_CHANGE | IN_MODIFIED;
if (vap->va_atime.tv_sec != VNOVAL) {
ip->i_flag &= ~IN_ACCESS;
DIP_SET(ip, i_atime, vap->va_atime.tv_sec);
DIP_SET(ip, i_atimensec, vap->va_atime.tv_nsec);
}
if (vap->va_mtime.tv_sec != VNOVAL) {
ip->i_flag &= ~IN_UPDATE;
DIP_SET(ip, i_mtime, vap->va_mtime.tv_sec);
DIP_SET(ip, i_mtimensec, vap->va_mtime.tv_nsec);
}