Nanosecond resolution for stat(2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Andrew Pimlott
I assume you mean "theoretical" that an application would care, not that it would happen. (Unless I misunderstand, it is nearly guaranteed to happen every time an inode is evicted after a [mac]time update.)
Only when you use an old file system. I tguess even ext2 and ext3 will learn about nsec timestamps eventually (e.g. by increasing the inode to the next power of two because there are many other contenders for new inode fields too)
Quoted 3 lines
I fear that there are applications that will be harmed by any spurious change in [mac]time, even if it's not backwards. Apps that
When they only look at the second part nothing will change for them.
If applications that do look at nsecs have serious problems with this backwards jumping it's still possible to add upwards rounding. I didn't want to do this for the first cut to avoid over engineering.
Quoted 8 lines
Quoted 3 lines
If it should be one in practice
it could be fixed by rounding the time up in this case.This would mean that even "legacy" programs that only use second resolution would be affected, which seems worse. At least programs that recognize the nanosecond field are more likely to know about the issue.
Well, there is some change in behaviour. You have to live with that.
-Andi
A message that is not in the archive (sent off-list or not yet received): 15759.62593.58936.153791@notabene.cse.unsw.edu.au.suse.lists.linux.kernel
Quoted 7 lines · Neil Brown
Would it make sense, when loading a time from disk, for the low order, non-stored bits of the time to be initialised high rather than low. i.e. to 999,999,999 rather than 0.
This way time stamps would never seem to jump backwards, only forwards, which seems less likely to cause confusion and will mean that a change is not missed (I'm thinking NFS here where cache correctness depends heavily on mtime).
It would be possible, but I would only add it when there are actual problems with the current solution.
It looks like a bit of a hack.
Quoted 7 lines
Also, would it make sense, for filesystems that don't store the full resolution, to make that forward jump appear as early as possible. i.e. if the mtime (ctime/atime) is earlier than the current time at the resoltion of the filesystem, then make the mtime appear to be what it would be if reloaded from storage... Maybe an example would help.
That would require much more callbacks into the filesystem. The VFS changes the times, but it doesn't know what the resolution of the file system is.
In theory it could help a bit when the rounding is needed, but again to avoid overengineering early I would like to first see if the current KISS way works out well enough.
[note that when you want the "only flush once a second" optimization back you would need some of these callbacks anyways, so when doing it it may be a good idea to merge it with early increase]
Quoted 5 lines
Thus the only incorrect observation that an application can make is that there is an extra change at the end of a second when other changes were made. I think this is better than an apparent change suddenly becoming visible many minutes after the time of that apparent change, and definately better than a timestamp moving backwards.
Probably yes. But it's also much more intrusive for the kernel code.
It also has the drawback that the application can see times in the future in stat.
e.g. when someone does
touch file stat(file, &st) gettimeofday(&now) tvsub(&diff, &now, &st.st_mtime_ts)
Then diff may actually be negative. Which could also in theory break stuff. So you would trade one breakage for another. Let's see if KISS works out first :-)
-And