]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: convert to ctime accessor functions
authorJeff Layton <jlayton@kernel.org>
Tue, 14 Nov 2023 09:39:12 +0000 (10:39 +0100)
committerCarlos Maiolino <cem@kernel.org>
Tue, 14 Nov 2023 12:32:28 +0000 (13:32 +0100)
Source kernel commit: a0a415e34b57368acd262e1172720252c028b936

In later patches, we're going to change how the inode's ctime field is
used. Switch to using accessor functions instead of raw accesses of
inode->i_ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Message-Id: <20230705190309.579783-80-jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
include/xfs_inode.h
libxfs/xfs_inode_buf.c
libxfs/xfs_trans_inode.c

index 069fcf362ece6cce0e6953ac8cf33478f9459904..aefad99dcbc00902740c178605d581a480f141a9 100644 (file)
@@ -43,7 +43,7 @@ struct inode {
        uint64_t                i_version;
        struct timespec64       i_atime;
        struct timespec64       i_mtime;
-       struct timespec64       i_ctime;
+       struct timespec64       __i_ctime; /* use inode_*_ctime accessors! */
        spinlock_t              i_lock;
 };
 
@@ -69,6 +69,26 @@ static inline void ihold(struct inode *inode)
        inode->i_count++;
 }
 
+/* Userspace does not support multigrain timestamps incore. */
+#define I_CTIME_QUERIED                        (0)
+
+static inline struct timespec64 inode_get_ctime(const struct inode *inode)
+{
+       struct timespec64 ctime;
+
+       ctime.tv_sec = inode->__i_ctime.tv_sec;
+       ctime.tv_nsec = inode->__i_ctime.tv_nsec & ~I_CTIME_QUERIED;
+
+       return ctime;
+}
+
+static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
+                                                    struct timespec64 ts)
+{
+       inode->__i_ctime = ts;
+       return ts;
+}
+
 typedef struct xfs_inode {
        struct cache_node       i_node;
        struct xfs_mount        *i_mount;       /* fs mount struct ptr */
index cbcaadbcf69cb1f090781886b1d8fc945cd58975..fccab4193541b36479555f47c95c1b4ecb59e4d9 100644 (file)
@@ -219,7 +219,8 @@ xfs_inode_from_disk(
         */
        inode->i_atime = xfs_inode_from_disk_ts(from, from->di_atime);
        inode->i_mtime = xfs_inode_from_disk_ts(from, from->di_mtime);
-       inode->i_ctime = xfs_inode_from_disk_ts(from, from->di_ctime);
+       inode_set_ctime_to_ts(inode,
+                             xfs_inode_from_disk_ts(from, from->di_ctime));
 
        ip->i_disk_size = be64_to_cpu(from->di_size);
        ip->i_nblocks = be64_to_cpu(from->di_nblocks);
@@ -313,7 +314,7 @@ xfs_inode_to_disk(
 
        to->di_atime = xfs_inode_to_disk_ts(ip, inode->i_atime);
        to->di_mtime = xfs_inode_to_disk_ts(ip, inode->i_mtime);
-       to->di_ctime = xfs_inode_to_disk_ts(ip, inode->i_ctime);
+       to->di_ctime = xfs_inode_to_disk_ts(ip, inode_get_ctime(inode));
        to->di_nlink = cpu_to_be32(inode->i_nlink);
        to->di_gen = cpu_to_be32(inode->i_generation);
        to->di_mode = cpu_to_be16(inode->i_mode);
index c4f81e5d12a231641b600fac6d37479555f93a2e..ca8e823762c9182a75debe257580a7a8303d6fa3 100644 (file)
@@ -64,7 +64,7 @@ xfs_trans_ichgtime(
        if (flags & XFS_ICHGTIME_MOD)
                inode->i_mtime = tv;
        if (flags & XFS_ICHGTIME_CHG)
-               inode->i_ctime = tv;
+               inode_set_ctime_to_ts(inode, tv);
        if (flags & XFS_ICHGTIME_CREATE)
                ip->i_crtime = tv;
 }