ufs_itimes_locked() seems to operate on individual files, and use a
different timestamp on each invocation. If multiple files have "marked for
update", and a periodic update occurs, then (if I read the spec correctly)
***all*** marked-for-update files have to have ***the same timestamp***.
Now, it could be that ufs only updates timestamps on a stat or close or
similar (ie no period ever occurs - this is one possible interpretation of
the "periodic update" scenario). But the problem with this implementation
is that some times that are "marked for update" may need to be written to
disk without a stat, close, or similar. At this point, an actual time value
presumably has to be chosen, and *all* marked-for-update timestamps have to
be updated (whether they are updated on-disk or not). But at this point,
any performance benefit from delaying the timestamp update is presumably
mostly mitigated by having to walk the in-memory list of marked-for-update
files and update them.
Looking at the spec, my issue is with the sentence (Base defns, 4.8) "At
the point in time when an update occurs, any marked timestamps shall be set
to the current time and the update marks shall be cleared."
My guess is that no file system implementations actually perform a
"periodic update" as described here (where *all* marked-for-update
timestamps on *all* files are updated with a single time value).
Does this make sense?
Post by Geoff ClarePost by Tom RidgeMy understanding of the
"periodic timestamp updates" is that this is describing the behaviour
observable within the POSIX operating system. Given this, I don't
understand why the "periodic timestamp updates" behaviour is mentioned,
given that no operating systems actually do this (and it is hard to
conceive that any would want to). Can someone describe the motivation for
this part of POSIX?
I'm confused. Given what Konrad said ("periodically" means from time
to time, or as needed, not that there's a set period of time), don't
all POSIX systems do it (at least for "normal" file systems)?
See for example the ufs_itimes_locked() function in
https://github.com/freebsd/freebsd/blob/master/sys/ufs/ufs/ufs_vnops.c
This looks to see which timestamps have been "marked for update"
(IN_ACCESS, IN_CHANGE or IN_UPDATE set), and sets the corresponding
if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) == 0)
return;
[...]
vfs_timestamp(&ts);
if (ip->i_flag & IN_ACCESS) {
DIP_SET(ip, i_atime, ts.tv_sec);
DIP_SET(ip, i_atimensec, ts.tv_nsec);
}
if (ip->i_flag & IN_UPDATE) {
DIP_SET(ip, i_mtime, ts.tv_sec);
DIP_SET(ip, i_mtimensec, ts.tv_nsec);
}
if (ip->i_flag & IN_CHANGE) {
DIP_SET(ip, i_ctime, ts.tv_sec);
DIP_SET(ip, i_ctimensec, ts.tv_nsec);
DIP_SET(ip, i_modrev, DIP(ip, i_modrev) + 1);
}
ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE);
Read and write operations just set the appropriate IN_* flags; the
actual timestamp update is done at some later time by this function
(e.g. on a close() or stat()).
--
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England