linux/include
Jeff Layton 4e40eff0b5
fs: add infrastructure for multigrain timestamps
The VFS has always used coarse-grained timestamps when updating the
ctime and mtime after a change. This has the benefit of allowing
filesystems to optimize away a lot metadata updates, down to around 1
per jiffy, even when a file is under heavy writes.

Unfortunately, this has always been an issue when we're exporting via
NFSv3, which relies on timestamps to validate caches. A lot of changes
can happen in a jiffy, so timestamps aren't sufficient to help the
client decide when to invalidate the cache. Even with NFSv4, a lot of
exported filesystems don't properly support a change attribute and are
subject to the same problems with timestamp granularity. Other
applications have similar issues with timestamps (e.g backup
applications).

If fine-grained timestamps were always used, that would improve the
situation, but that becomes rather expensive, as the underlying
filesystem would have to log a lot more metadata updates.

What is needed is a way to only use fine-grained timestamps when they
are being actively queried. Use the (unused) top bit in
inode->i_ctime_nsec as a flag that indicates whether the current
timestamps have been queried via stat() or the like. When it's set,
allow the update to use a fine-grained timestamp iff it's necessary to
make the ctime show a different value.

If it has been queried, then first see whether the current coarse time
is later than the existing ctime. If it is, accept that value.  If it
isn't, then get a fine-grained timestamp and attempt to stamp the inode
ctime with that value. If that races with another concurrent stamp, then
abandon the update and take the new value without retrying.

Filesystems can opt into this by setting the FS_MGTIME fstype flag.
Others should be unaffected (other than being subject to the same floor
value as multigrain filesystems).

Tested-by: Randy Dunlap <rdunlap@infradead.org> # documentation bits
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20241002-mgtime-v10-3-d1c4717f5284@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-07 12:48:56 +02:00
..
acpi ACPI: video: Add Dell UART backlight controller detection 2024-08-19 15:58:35 +02:00
asm-generic runtime constants: deal with old decrepit linkers 2024-08-03 08:38:45 -07:00
clocksource
crypto
drm A revert for a previous TTM commit causing stuttering, 3 fixes for 2024-08-30 11:28:11 +10:00
dt-bindings I3C for 6.11 2024-07-27 10:53:06 -07:00
keys
kunit kunit: Fix missing kerneldoc comment 2024-09-05 14:29:10 -06:00
kvm
linux fs: add infrastructure for multigrain timestamps 2024-10-07 12:48:56 +02:00
math-emu
media
memory
misc
net net: mana: Fix error handling in mana_create_txq/rxq's NAPI cleanup 2024-09-04 11:50:04 +01:00
pcmcia
ras
rdma
rv
scsi scsi: core: Fix the return value of scsi_logical_block_count() 2024-08-16 21:02:06 -04:00
soc net: mscc: ocelot: treat 802.1ad tagged traffic as 802.1Q-untagged 2024-08-16 09:59:32 +01:00
sound ASoC: Fixes for v6.11 2024-09-06 08:24:56 +02:00
target
trace rpcrdma: Trace connection registration and unregistration 2024-08-19 11:50:41 -04:00
uapi sound fixes for 6.11-rc7 2024-09-06 11:56:03 -07:00
ufs scsi: ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register 2024-08-16 21:09:17 -04:00
vdso Random number generator updates for Linux 6.11-rc1. 2024-07-24 10:29:50 -07:00
video
xen Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00