]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: switch to multigrain timestamps
authorJeff Layton <jlayton@kernel.org>
Tue, 14 Nov 2023 09:47:49 +0000 (10:47 +0100)
committerCarlos Maiolino <cem@kernel.org>
Tue, 14 Nov 2023 12:32:50 +0000 (13:32 +0100)
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>
include/xfs_inode.h
libxfs/xfs_trans_inode.c

index aefad99dcbc00902740c178605d581a480f141a9..dd07d0f34f574dcf2d8729e72fd2a4dc7676196c 100644 (file)
@@ -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 **);
index ca8e823762c9182a75debe257580a7a8303d6fa3..7a6ecb5db0d85e3420a9709f09c2e411b93b9325 100644 (file)
@@ -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;
 }