4 ms·
The reason why ext4 and xfs both use nanosecond resolution is because in the kernel the high precision time keeping structure is the timespec structure (which o
by tytso 6y ago
The reason why ext4 and xfs both use nanosecond resolution is because in the kernel the high precision time keeping structure is the timespec structure (which originally was defined by POSIX). That uses tv_sec and tv_nsec. Certainly in 2008, when ext4 was declared "stable", the hardware of the time was nowhere near having the necessary resolution to give us nanosecond accuract. However, that's not really the point. We want to be able to store an arbitrary timespec value, encode it in the file system timestamp, and then decode it back to a bit-identical timespec value. So that's why it makes sense to use at least a nanosecond granularity.
Why not use a finer granularity? Because space in the on-disk inode structure is precious. We need 30 bits to encode nanoseconds. That leaves an extra two bits that can be added to 32 bit "time in seconds since the Unix epoch". For full backwards compatibility, where a "negative" tv_sec corresponds to times before 1970, that gets you to the 25th century. If we really cared, we could add an extra 500 years by stealing a bit somewhere from the inode (maybe an unused flag bit, perhaps --- but since there are 4 timestamps in an inode, you would need to steal 4 bits for each doubling of time range). However, there is no guarantee that ext4 or xfs will be used 400-500 years from now; and if it is being used, it seems likely that there will plenty of time to do another format bump; XFS has had 4 incompatible fomat bumps in the last 27 years. ext2/ext3/ext4 has been around for 28 years, and depending on how you count, there has been 2-4 major version bumps (we use finer-grained feature bits, so it's a bit hard to count). In the next 500 years, we'll probably have a few more. :-)
- throwaway_pdp09 6y agoI'm afraid I don't get this at all. Use of data should define the data... > The reason why ext4 and xfs both use nanosecond resolution is because in the kernel the high precision time keeping structure is the timespec structure ...so resolution here is defined by what's provided, not what's (decided to be) useful. Is ns resolution useful is the important question. > Why not use a finer granularity? Because space in the on-disk inode structure is precious That's not a good reason AFAICS. What would it gain your users if you did? 1 ns = ~4 machine cycles. Timestamping to that res, well, what's the value to any application? I'm missing something.
- emteycz 6y agoYou can sometimes see timestamps from other machines too, they can also be parallel
- throwaway_pdp09 6y agoI'm being dense, I don't understand what you're saying. Could you give a bit more detail please?
- emteycz 6y agoWhat my machine can or can not do is irrelevant, I might connect a drive from a machine where machine cycles were faster or parallel. So it's entirely possible to see timestamps less than X nanoseconds apart even if my machine can't do more than one cycle each X nanoseconds.
- throwaway_pdp09 6y agoHow would that make any possible difference to you? Bear in mind 1ns = the time a ray of light would travel 30cm in a vacuum.
- emteycz 6y agoI imagine it could make a difference in court in some cases.
- throwaway_pdp09 6y agoWith respect, no way. FIPS mandates a timestamp resolution of 10 microseconds. 10,100 times smaller that is literally meaningless.
- emteycz 6y agoThanks for correcting me on that! I still think it could be useful to people, though. Do you think it's that wasteful? The machines of today are powerful and have plenty of disk space.