2023-08-07 19:47:35

by Jeffrey Layton

[permalink] [raw]
Subject: [PATCH v7 00/13] fs: implement multigrain timestamps

The VFS always uses 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 coarseness 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 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. The idea is to use an unused bit in the ctime's
tv_nsec field to mark when the mtime or ctime has been queried via
getattr. Once that has been marked, the next m/ctime update will use a
fine-grained timestamp.

Credit goes to Dave Chinner for the original idea, and to Ben Coddington
for the catchy name. This series should apply cleanly onto Christian's
vfs.ctime branch, once the v6 mgtime patches have been dropped. That
should be everything above this commit:

525deaeb2fbf gfs2: fix timestamp handling on quota inodes

base-commit: cf22d118b89a09a0160586412160d89098f7c4c7
Signed-off-by: Jeff Layton <[email protected]>
---
Changes in v7:
- change update_time operation to fetch the current time itself
- don't modify current_time operation. Leave it always returning coarse timestamp
- rework inode_set_ctime_current for better atomicity and ensure that
all mgtime filesystems use it
- reorder arguments to fill_mg_cmtime

Changes in v6:
- drop the patch that removed XFS_ICHGTIME_CHG
- change WARN_ON_ONCE to ASSERT in xfs conversion patch

---
Jeff Layton (13):
fs: remove silly warning from current_time
fs: pass the request_mask to generic_fillattr
fs: drop the timespec64 arg from generic_update_time
btrfs: have it use inode_update_timestamps
fat: make fat_update_time get its own timestamp
ubifs: have ubifs_update_time use inode_update_timestamps
xfs: have xfs_vn_update_time gets its own timestamp
fs: drop the timespec64 argument from update_time
fs: add infrastructure for multigrain timestamps
tmpfs: add support for multigrain timestamps
xfs: switch to multigrain timestamps
ext4: switch to multigrain timestamps
btrfs: convert to multigrain timestamps

fs/9p/vfs_inode.c | 4 +-
fs/9p/vfs_inode_dotl.c | 4 +-
fs/afs/inode.c | 2 +-
fs/bad_inode.c | 3 +-
fs/btrfs/file.c | 24 +----
fs/btrfs/inode.c | 14 +--
fs/btrfs/super.c | 5 +-
fs/btrfs/volumes.c | 4 +-
fs/ceph/inode.c | 2 +-
fs/coda/inode.c | 3 +-
fs/ecryptfs/inode.c | 5 +-
fs/erofs/inode.c | 2 +-
fs/exfat/file.c | 2 +-
fs/ext2/inode.c | 2 +-
fs/ext4/inode.c | 2 +-
fs/ext4/super.c | 2 +-
fs/f2fs/file.c | 2 +-
fs/fat/fat.h | 3 +-
fs/fat/file.c | 2 +-
fs/fat/misc.c | 6 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 8 +-
fs/hfsplus/inode.c | 2 +-
fs/inode.c | 200 +++++++++++++++++++++++++++++++---------
fs/kernfs/inode.c | 2 +-
fs/libfs.c | 4 +-
fs/minix/inode.c | 2 +-
fs/nfs/inode.c | 2 +-
fs/nfs/namespace.c | 3 +-
fs/ntfs3/file.c | 2 +-
fs/ocfs2/file.c | 2 +-
fs/orangefs/inode.c | 5 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/proc/base.c | 4 +-
fs/proc/fd.c | 2 +-
fs/proc/generic.c | 2 +-
fs/proc/proc_net.c | 2 +-
fs/proc/proc_sysctl.c | 2 +-
fs/proc/root.c | 3 +-
fs/smb/client/inode.c | 2 +-
fs/smb/server/smb2pdu.c | 22 ++---
fs/smb/server/vfs.c | 3 +-
fs/stat.c | 65 ++++++++++---
fs/sysv/itree.c | 3 +-
fs/ubifs/dir.c | 2 +-
fs/ubifs/file.c | 19 ++--
fs/ubifs/ubifs.h | 2 +-
fs/udf/symlink.c | 2 +-
fs/vboxsf/utils.c | 2 +-
fs/xfs/libxfs/xfs_trans_inode.c | 6 +-
fs/xfs/xfs_iops.c | 25 +++--
fs/xfs/xfs_super.c | 2 +-
include/linux/fs.h | 55 +++++++++--
mm/shmem.c | 4 +-
55 files changed, 368 insertions(+), 192 deletions(-)
---
base-commit: 525deaeb2fbf634222f4231608c72190c551c935
change-id: 20230713-mgctime-f2a9fc324918

Best regards,
--
Jeff Layton <[email protected]>



2023-08-07 19:49:01

by Jeffrey Layton

[permalink] [raw]
Subject: [PATCH v7 10/13] tmpfs: add support for multigrain timestamps

Enable multigrain timestamps, which should ensure that there is an
apparent change to the timestamp whenever it has been written after
being actively observed via getattr.

tmpfs only requires the FS_MGTIME flag.

Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Jeff Layton <[email protected]>
---
mm/shmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 142ead70e8c1..98cc4be7a8a8 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4220,7 +4220,7 @@ static struct file_system_type shmem_fs_type = {
#endif
.kill_sb = kill_litter_super,
#ifdef CONFIG_SHMEM
- .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
+ .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME,
#else
.fs_flags = FS_USERNS_MOUNT,
#endif

--
2.41.0


2023-09-04 18:47:04

by patchwork-bot+f2fs

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH v7 00/13] fs: implement multigrain timestamps

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Christian Brauner <[email protected]>:

On Mon, 07 Aug 2023 15:38:31 -0400 you wrote:
> The VFS always uses 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 coarseness 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 to invalidate the cache.
>
> [...]

Here is the summary with links:
- [f2fs-dev,v7,01/13] fs: remove silly warning from current_time
https://git.kernel.org/jaegeuk/f2fs/c/b3030e4f2344
- [f2fs-dev,v7,02/13] fs: pass the request_mask to generic_fillattr
https://git.kernel.org/jaegeuk/f2fs/c/0d72b92883c6
- [f2fs-dev,v7,03/13] fs: drop the timespec64 arg from generic_update_time
https://git.kernel.org/jaegeuk/f2fs/c/541d4c798a59
- [f2fs-dev,v7,04/13] btrfs: have it use inode_update_timestamps
https://git.kernel.org/jaegeuk/f2fs/c/bb7cc0a62e47
- [f2fs-dev,v7,05/13] fat: make fat_update_time get its own timestamp
(no matching commit)
- [f2fs-dev,v7,06/13] ubifs: have ubifs_update_time use inode_update_timestamps
(no matching commit)
- [f2fs-dev,v7,07/13] xfs: have xfs_vn_update_time gets its own timestamp
(no matching commit)
- [f2fs-dev,v7,08/13] fs: drop the timespec64 argument from update_time
(no matching commit)
- [f2fs-dev,v7,09/13] fs: add infrastructure for multigrain timestamps
https://git.kernel.org/jaegeuk/f2fs/c/ffb6cf19e063
- [f2fs-dev,v7,10/13] tmpfs: add support for multigrain timestamps
https://git.kernel.org/jaegeuk/f2fs/c/d48c33972916
- [f2fs-dev,v7,11/13] xfs: switch to multigrain timestamps
(no matching commit)
- [f2fs-dev,v7,12/13] ext4: switch to multigrain timestamps
https://git.kernel.org/jaegeuk/f2fs/c/0269b585868e
- [f2fs-dev,v7,13/13] btrfs: convert to multigrain timestamps
https://git.kernel.org/jaegeuk/f2fs/c/50e9ceef1d4f

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html