]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: convert to new timestamp accessors
authorJeff Layton <jlayton@kernel.org>
Thu, 15 Feb 2024 08:25:40 +0000 (09:25 +0100)
committerCarlos Maiolino <cem@kernel.org>
Thu, 15 Feb 2024 11:56:43 +0000 (12:56 +0100)
Source kernel commit: 75d1e312bbbd175fa27ffdd4c4fe9e8cc7d047ec

Convert to using the new inode timestamp accessor functions.

[Carlos: Also partially port 077c212f0344ae and 12cd4402365166]
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20231004185347.80880-75-jlayton@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
include/xfs_inode.h
libxfs/util.c
libxfs/xfs_inode_buf.c
libxfs/xfs_rtbitmap.c
libxfs/xfs_trans_inode.c
mkfs/proto.c

index 986815e5cf75ad17b65610bcdb08ef43479ef4c0..a351bb0d9040f155591faf163156cdd1efc4f593 100644 (file)
@@ -41,8 +41,8 @@ struct inode {
        unsigned long           i_state; /* Not actually used in userspace */
        uint32_t                i_generation;
        uint64_t                i_version;
-       struct timespec64       i_atime;
-       struct timespec64       i_mtime;
+       struct timespec64       __i_atime;
+       struct timespec64       __i_mtime;
        struct timespec64       __i_ctime; /* use inode_*_ctime accessors! */
        spinlock_t              i_lock;
 };
@@ -69,6 +69,76 @@ static inline void ihold(struct inode *inode)
        inode->i_count++;
 }
 
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+       return inode->__i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+       return inode->__i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+       return inode->__i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+                                                     struct timespec64 ts)
+{
+       inode->__i_atime = ts;
+       return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+                                               time64_t sec, long nsec)
+{
+       struct timespec64 ts = { .tv_sec = sec,
+                                .tv_nsec = nsec };
+       return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+       return inode->__i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+       return inode->__i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+       return inode->__i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+                                                     struct timespec64 ts)
+{
+       inode->__i_mtime = ts;
+       return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+                                               time64_t sec, long nsec)
+{
+       struct timespec64 ts = { .tv_sec = sec,
+                                .tv_nsec = nsec };
+       return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+       return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+       return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
        return inode->__i_ctime;
index 8f79b0cd17b7b648b5c2c0bb2506553d30d31957..8517bfb64b5260fa282fe10ce2d9f7476e56e54c 100644 (file)
@@ -291,7 +291,7 @@ libxfs_init_new_inode(
                if (!pip)
                        ip->i_diflags2 = xfs_flags2diflags2(ip,
                                                        fsx->fsx_xflags);
-               ip->i_crtime = VFS_I(ip)->i_mtime; /* struct copy */
+               ip->i_crtime = inode_get_mtime(VFS_I(ip)); /* struct copy */
                ip->i_cowextsize = pip ? 0 : fsx->fsx_cowextsize;
        }
 
index fccab4193541b36479555f47c95c1b4ecb59e4d9..74a1bd22741db4cdfa4a603255c2e01f8787121b 100644 (file)
@@ -217,8 +217,10 @@ xfs_inode_from_disk(
         * a time before epoch is converted to a time long after epoch
         * on 64 bit systems.
         */
-       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_set_atime_to_ts(inode,
+                             xfs_inode_from_disk_ts(from, from->di_atime));
+       inode_set_mtime_to_ts(inode,
+                             xfs_inode_from_disk_ts(from, from->di_mtime));
        inode_set_ctime_to_ts(inode,
                              xfs_inode_from_disk_ts(from, from->di_ctime));
 
@@ -312,8 +314,8 @@ xfs_inode_to_disk(
        to->di_projid_lo = cpu_to_be16(ip->i_projid & 0xffff);
        to->di_projid_hi = cpu_to_be16(ip->i_projid >> 16);
 
-       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_atime = xfs_inode_to_disk_ts(ip, inode_get_atime(inode));
+       to->di_mtime = xfs_inode_to_disk_ts(ip, inode_get_mtime(inode));
        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);
index c635e8c2e2cba035872730a4acc481b625a23730..9a8bd93b7b9006c7f29be60d25103bfaf213564a 100644 (file)
@@ -974,6 +974,7 @@ xfs_rtfree_extent(
        xfs_mount_t     *mp;            /* file system mount structure */
        xfs_fsblock_t   sb;             /* summary file block number */
        struct xfs_buf  *sumbp = NULL;  /* summary file block buffer */
+       struct timespec64 atime;
 
        mp = tp->t_mountp;
 
@@ -1003,7 +1004,10 @@ xfs_rtfree_extent(
            mp->m_sb.sb_rextents) {
                if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
                        mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
-               *(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
+
+               atime = inode_get_atime(VFS_I(mp->m_rbmip));
+               atime.tv_sec = 0;
+               inode_set_atime_to_ts(VFS_I(mp->m_rbmip), atime);
                xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
        }
        return 0;
index ca8e823762c9182a75debe257580a7a8303d6fa3..c171a525cefb71e2ff62a6ccaebe0b5852feaf2f 100644 (file)
@@ -62,7 +62,7 @@ xfs_trans_ichgtime(
        tv = current_time(inode);
 
        if (flags & XFS_ICHGTIME_MOD)
-               inode->i_mtime = tv;
+               inode_set_mtime_to_ts(inode, tv);
        if (flags & XFS_ICHGTIME_CHG)
                inode_set_ctime_to_ts(inode, tv);
        if (flags & XFS_ICHGTIME_CREATE)
index ea31cfe5cfc0f6feac373dbf3af6cdaedebd6b06..e9c633ed367147d6120cb083ebcf364bab399f56 100644 (file)
@@ -688,7 +688,7 @@ rtinit(
        mp->m_sb.sb_rbmino = rbmip->i_ino;
        rbmip->i_disk_size = mp->m_sb.sb_rbmblocks * mp->m_sb.sb_blocksize;
        rbmip->i_diflags = XFS_DIFLAG_NEWRTBM;
-       *(uint64_t *)&VFS_I(rbmip)->i_atime = 0;
+       inode_set_atime(VFS_I(rbmip), 0, 0);
        libxfs_trans_log_inode(tp, rbmip, XFS_ILOG_CORE);
        libxfs_log_sb(tp);
        mp->m_rbmip = rbmip;