Multigrain timestamps
Multigrain timestamps are a Linux filesystem mechanism that selectively refines inode timestamp updates after modification or change times have been queried.
In Linux v7.2, fill_mg_cmtime marks an inode queried when STATX_CTIME or STATX_MTIME is requested; a request for neither does not set the marker or clear an earlier mark. inode_set_ctime_current uses fine time when the marker is set and coarse time would not advance ctime. Values are still truncated to the filesystem's supported granularity. [2] [3]
A global floor prevents a later coarse timestamp from falling behind an earlier fine timestamp during non-overlapping modifications, assuming no backward realtime-clock jump. Equality remains possible; operations that overlap have no submission-order guarantee. The floor uses monotonic time internally but exported timestamps remain realtime values. [1]
Local filesystems opt in through FS_MGTIME and the required timestamp paths. This is not a universal promise for every mount. The refinement concerns mtime and ctime, not atime. [1]
For synchronization, this mechanism cannot prevent an authorized caller from restoring mtime with utimensat. Default rsync selection compares size and mtime and ignores nanoseconds; --modify-window=-1 can compare nanoseconds with a sufficiently recent receiver. Even that comparison can miss changed bytes with an exactly restored mtime. [4] [5]
NFS connection: local filesystem timestamp refinement can improve the ctime values used by a server's change-attribute fallback. Network filesystems that mirror server timestamps do not acquire local FS_MGTIME semantics merely because the client runs this kernel. Inspect the server's backing filesystem and returned attributes. [1]
Relations
- related
- File modification time, Inode change time, File access time, Rsync quick check, Lazy timestamp persistence, NFS, NFS change attribute
Advantages
- Makes queried timestamp changes easier to distinguish without requiring fine timestamps for every update. [2, 3]
Limitations
Citations
- Linux 7.2: Multigrain Timestamps, ordering, floor and filesystem opt-in
- Linux v7.2 fs/stat.c: fill_mg_cmtime and requested timestamp fields
- Linux v7.2 fs/inode.c: inode_set_ctime_current and timestamp_truncate
- Linux utimensat(2): explicit timestamp assignment and ctime updates
- Rsync manual: quick check and modify-window timestamp precision
- Hesela: timestamp comparison and rsync file selection
Sources & caveats
- Source synthesis pinned to Linux v7.2. No native multigrain experiment, kernel introduction-date claim or measured performance gain. Earlier rsync fixtures are separate observations, not tests of this kernel mechanism.