[PATCH v2 0/3] fs: multigrain timestamps

Jeff Layton
2023-04-24T15:11:13Z

A few weeks ago, during one of the discussions around i_version, Dave
Chinner wrote this:

"You've missed the part where I suggested lifting the "nfsd sampled
i_version" state into an inode state flag rather than hiding it in
the i_version field. At that point, we could optimise away the
secondary ctime updates just like you are proposing we do with the
i_version updates. Further, we could also use that state it to
decide whether we need to use high resolution timestamps when
recording ctime updates - if the nfsd has not sampled the
ctime/i_version, we don't need high res timestamps to be recorded
for ctime...."

While I don't think we can practically optimize away ctime updates
like we do with i_version, I do like the idea of using this scheme to
indicate when we need to use a high-res timestamp.

This patchset is a second attempt at implementing this. The main
difference with this set is that it uses the lowest-order bit of the
tv_nsec field as the flag instead of using an i_state flag. This also
allows us to use atomic ops instead of a spinlock.

With this, the patchset also contains a new opt-in mechanism: You must
set a SB_MULTIGRAIN_TS flag in the superblock, and also raise your
sb->s_time_gran to at least 2.

The first patch adds the necessary infrastructure, and the last two
patches convert tmpfs and xfs to use it. If this looks good, I'll start
embarking on converting other filesystems to this scheme as well.

Comments and suggestions welcome!

Jeff Layton (3):
fs: add infrastructure for multigrain inode i_m/ctime
shmem: mark for high-res timestamps on next update after getattr
xfs: mark the inode for high-res timestamp update in getattr

fs/inode.c | 57 +++++++++++++++++++++++++++---
fs/stat.c | 24 +++++++++++++
fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
fs/xfs/xfs_acl.c | 2 +-
fs/xfs/xfs_inode.c | 2 +-
fs/xfs/xfs_inode_item.c | 2 +-
fs/xfs/xfs_iops.c | 9 +++--
fs/xfs/xfs_super.c | 5 ++-
include/linux/fs.h | 62 +++++++++++++++++++++++----------
mm/shmem.c | 29 ++++++++-------
10 files changed, 152 insertions(+), 42 deletions(-)

--
2.40.0