diff options
author | Jeff Layton <jlayton@kernel.org> | 2023-11-14 10:47:49 +0100 |
---|---|---|
committer | Carlos Maiolino <cem@kernel.org> | 2023-11-14 13:32:50 +0100 |
commit | f99988c2fbfea7b19b8ef174ba0175a540861f10 (patch) | |
tree | 2b714169dff2d20403cd069f17b3d34a2ce5175f | |
parent | be49fa968f98cf797b16aa279b11c431199b3af3 (diff) | |
download | xfsprogs-dev-f99988c2fbfea7b19b8ef174ba0175a540861f10.tar.gz |
xfs: switch to multigrain timestamps
Source kernel commit: e44df2664746aed8b6dd5245eb711a0ce33c5cf5
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.
Also, anytime the mtime changes, the ctime must also change, and those
are now the only two options for xfs_trans_ichgtime. Have that function
unconditionally bump the ctime, and ASSERT that XFS_ICHGTIME_CHG is
always set.
Acked-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Message-Id: <20230807-mgctime-v7-11-d1dec143a704@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r-- | include/xfs_inode.h | 12 | ||||
-rw-r--r-- | libxfs/xfs_trans_inode.c | 6 |
2 files changed, 13 insertions, 5 deletions
diff --git a/include/xfs_inode.h b/include/xfs_inode.h index aefad99dcb..dd07d0f34f 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -89,6 +89,16 @@ static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, return ts; } +extern struct timespec64 current_time(struct inode *inode); + +static inline struct timespec64 inode_set_ctime_current(struct inode *inode) +{ + struct timespec64 now = current_time(inode); + + inode_set_ctime_to_ts(inode, now); + return now; +} + typedef struct xfs_inode { struct cache_node i_node; struct xfs_mount *i_mount; /* fs mount struct ptr */ @@ -271,8 +281,6 @@ extern void libxfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); extern int libxfs_iflush_int (struct xfs_inode *, struct xfs_buf *); -extern struct timespec64 current_time(struct inode *inode); - /* Inode Cache Interfaces */ extern int libxfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, uint, struct xfs_inode **); diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c index ca8e823762..7a6ecb5db0 100644 --- a/libxfs/xfs_trans_inode.c +++ b/libxfs/xfs_trans_inode.c @@ -59,12 +59,12 @@ xfs_trans_ichgtime( ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - tv = current_time(inode); + /* If the mtime changes, then ctime must also change */ + ASSERT(flags & XFS_ICHGTIME_CHG); + tv = inode_set_ctime_current(inode); if (flags & XFS_ICHGTIME_MOD) inode->i_mtime = tv; - if (flags & XFS_ICHGTIME_CHG) - inode_set_ctime_to_ts(inode, tv); if (flags & XFS_ICHGTIME_CREATE) ip->i_crtime = tv; } |