linux/Documentation/filesystems
Christian Brauner b40508ca5d
Merge patch series "timekeeping/fs: multigrain timestamp redux"
Jeff Layton <jlayton@kernel.org> says:

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 we were to always use fine-grained timestamps, that would improve the
situation, but that becomes rather expensive, as the underlying
filesystem would have to log a lot more metadata updates.

What we need 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, we allow the kernel to
use a fine-grained timestamp iff it's necessary to make the ctime show
a different value.

This solves the problem of being able to distinguish the timestamp
between updates, but introduces a new problem: it's now possible for a
file being changed to get a fine-grained timestamp. A file that is
altered just a bit later can then get a coarse-grained one that appears
older than the earlier fine-grained time. This violates timestamp
ordering guarantees.

To remedy this, keep a global monotonic atomic64_t value that acts as a
timestamp floor.  When we go to stamp a file, we first get the latter of
the current floor value and the current coarse-grained time. If the
inode ctime hasn't been queried then we just attempt to stamp it with
that value.

If it has been queried, then first see whether the current coarse time
is later than the existing ctime. If it is, then we accept that value.
If it isn't, then we get a fine-grained time and try to swap that into
the global floor. Whether that succeeds or fails, we take the resulting
floor time, convert it to realtime and try to swap that into the ctime.

We take the result of the ctime swap whether it succeeds or fails, since
either is just as valid.

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).

* patches from https://lore.kernel.org/r/20241002-mgtime-v10-0-d1c4717f5284@kernel.org:
  tmpfs: add support for multigrain timestamps
  btrfs: convert to multigrain timestamps
  ext4: switch to multigrain timestamps
  xfs: switch to multigrain timestamps
  Documentation: add a new file documenting multigrain timestamps
  fs: add percpu counters for significant multigrain timestamp events
  fs: tracepoints around multigrain timestamp events
  fs: handle delegated timestamps in setattr_copy_mgtime
  fs: have setattr_copy handle multigrain timestamps appropriately
  fs: add infrastructure for multigrain timestamps

Link: https://lore.kernel.org/r/20241002-mgtime-v10-0-d1c4717f5284@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-10 10:20:57 +02:00
..
bcachefs bcachefs: Fix a spelling error in docs 2024-09-09 09:41:48 -04:00
caching netfs: clean up after renaming FSCACHE_DEBUG config 2024-08-12 22:03:26 +02:00
ext4 Documentation: Fix typos 2023-08-18 11:29:03 -06:00
iomap vfs-6.12.blocksize 2024-09-20 17:53:17 -07:00
nfs nfs: Fix make htmldocs warnings in the localio documentation 2024-09-24 11:16:34 -04:00
smb ksmbd: fix spelling mistakes in documentation 2024-08-18 17:02:36 -05:00
spufs Documentation: spufs: correct a duplicate word typo 2022-09-27 13:21:44 -06:00
xfs docs: describe xfs directory tree online fsck 2024-04-15 14:59:01 -07:00
9p.rst USB/Thunderbolt update for 6.12-rc1 2024-09-26 09:45:36 -07:00
adfs.rst
affs.rst
afs.rst afs: Documentation: correct reference to CONFIG_AFS_FS 2023-07-21 13:46:02 -06:00
api-summary.rst doc: split buffer.rst out of api-summary.rst 2024-05-05 17:53:40 -07:00
autofs-mount-control.rst autofs: use flexible array in ioctl structure 2023-05-30 16:42:00 -07:00
autofs.rst docs:filesystem: fix mispelled words on autofs page 2024-09-10 15:35:36 -06:00
automount-support.rst
befs.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
bfs.rst
btrfs.rst MAINTAINERS: remove links to obsolete btrfs.wiki.kernel.org 2023-09-08 14:21:27 +02:00
buffer.rst doc: split buffer.rst out of api-summary.rst 2024-05-05 17:53:40 -07:00
ceph.rst doc: ceph: update userspace command to get CephFS metadata 2024-05-23 10:35:47 +02:00
coda.rst
configfs.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
cramfs.rst
dax.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
debugfs.rst debugfs: small Documentation cleaning 2022-11-09 13:58:55 -07:00
devpts.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
directory-locking.rst Docs: typos/spelling 2024-05-02 10:02:29 -06:00
dlmfs.rst docs: update ocfs2-devel mailing list address 2023-07-08 09:29:29 -07:00
dnotify.rst
ecryptfs.rst
efivarfs.rst Documentation: Mark the 'efivars' sysfs interface as removed 2024-04-13 10:33:02 +02:00
erofs.rst erofs: allow large folios for compressed files 2024-08-19 16:10:04 +08:00
ext2.rst ext2: remove nobh support 2022-08-02 12:34:04 -04:00
ext3.rst
f2fs.rst f2fs: assign the write hint per stream by default 2024-04-19 17:56:13 +00:00
fiemap.rst
files.rst docs: filesystems: fix typo in docs 2024-02-09 10:37:20 +01:00
fscrypt.rst fscrypt: write CBC-CTS instead of CTS-CBC 2024-02-23 21:38:59 -08:00
fsverity.rst documentation: add IPE documentation 2024-08-20 14:03:47 -04:00
fuse-io.rst docs/fuse-io: Document the usage of DIRECT_IO_ALLOW_MMAP 2023-12-04 10:16:53 +01:00
fuse.rst fuse: Add module param for CAP_SYS_ADMIN access bypassing allow_other 2022-07-21 16:06:19 +02:00
gfs2-glocks.rst gfs2: Get rid of demote_ok checks 2024-05-29 15:34:55 +02:00
gfs2-uevents.rst
gfs2.rst
hfs.rst
hfsplus.rst
hpfs.rst
idmappings.rst doc: correcting the idmapping mount example 2024-08-30 08:22:37 +02:00
index.rst Documentation: add a new file documenting multigrain timestamps 2024-10-10 10:20:52 +02:00
inotify.rst
isofs.rst
journalling.rst docs:filesystems: fix spelling and grammar mistakes 2024-09-10 15:36:50 -06:00
locking.rst fs: Convert aops->write_begin to take a folio 2024-08-07 11:33:21 +02:00
locks.rst docs: fs: locks.rst: update comment about mandatory file locking 2021-10-19 06:48:21 -04:00
mount_api.rst fs_parse: add uid & gid option option parsing helpers 2024-07-02 06:20:49 +02:00
multigrain-ts.rst Documentation: add a new file documenting multigrain timestamps 2024-10-10 10:20:52 +02:00
netfs_library.rst docs: filesystems: corrected grammar of netfs page 2024-09-12 12:20:43 +02:00
nilfs2.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
ntfs3.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
ocfs2-online-filecheck.rst
ocfs2.rst docs: update ocfs2-devel mailing list address 2023-07-08 09:29:29 -07:00
omfs.rst
orangefs.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
overlayfs.rst overlayfs.rst: update metacopy section in overlayfs documentation 2024-09-08 15:36:38 +02:00
path-lookup.rst Merge branch 'work.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2021-07-03 11:41:14 -07:00
path-lookup.txt
porting.rst getting rid of bogus set_blocksize() uses, switching it 2024-05-21 08:34:51 -07:00
proc.rst docs/procfs: call out ioctl()-based PROCMAP_QUERY command existence 2024-07-12 15:52:12 -07:00
qnx6.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
quota.rst
ramfs-rootfs-initramfs.rst Documentation/filesystems: ramfs-rootfs-initramfs: use :Author: 2023-05-16 12:55:35 -06:00
relay.rst
romfs.rst
seq_file.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
sharedsubtree.rst Documentation/filesystems: sharedsubtree: add section headings 2023-05-16 12:50:05 -06:00
splice.rst
squashfs.rst docs: filesystems: document the squashfs specific mount options 2023-12-10 17:21:31 -08:00
sysfs.rst driver core: bus: mark the struct bus_type for sysfs callbacks as constant 2023-03-23 13:20:40 +01:00
sysv-fs.rst
tmpfs.rst tmpfs,xattr: enable limited user extended attributes 2023-08-10 12:06:04 +02:00
ubifs-authentication.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
ubifs.rst Documentation: ubifs: Fix compression idiom 2022-10-10 13:01:10 -06:00
udf.rst
vfat.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
vfs.rst ALong with the usual shower of singleton patches, notable patch series in 2024-09-21 07:29:05 -07:00
virtiofs.rst
zonefs.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00