From cb49e9a41477791af390a397c97da28da31fb81d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 22 Jan 2020 11:29:44 -0500 Subject: [PATCH] xfs: use a struct timespec64 for the in-core crtime Source kernel commit: 8d2d878db897d7501aaa2f72e10bb28295bb5498 struct xfs_icdinode is purely an in-memory data structure, so don't use a log on-disk structure for it. This simplifies the code a bit, and also reduces our include hell slightly. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong [darrick: fix a minor indenting problem in xfs_trans_ichgtime] Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- include/libxfs.h | 1 + include/xfs_inode.h | 1 - libxfs/libxfs_priv.h | 2 ++ libxfs/util.c | 4 ++-- libxfs/xfs_inode_buf.c | 8 ++++---- libxfs/xfs_inode_buf.h | 2 +- libxfs/xfs_trans_inode.c | 8 +++----- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 3b7c51fe4..aaac00f67 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -41,6 +41,7 @@ struct iomap; #define __round_mask(x, y) ((__typeof__(x))((y)-1)) #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) #define unlikely(x) (x) +#define timespec64 timespec /* * This mirrors the kernel include for xfs_buf.h - it's implicitly included in diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 9565adc1c..7345209a0 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -160,7 +160,6 @@ extern void libxfs_trans_ichgtime(struct xfs_trans *, struct xfs_inode *, int); extern int libxfs_iflush_int (struct xfs_inode *, struct xfs_buf *); -#define timespec64 timespec extern struct timespec64 current_time(struct inode *inode); /* Inode Cache Interfaces */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 462ab421a..03edf0d3e 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -62,6 +62,8 @@ extern kmem_zone_t *xfs_buf_zone; extern kmem_zone_t *xfs_inode_zone; extern kmem_zone_t *xfs_trans_zone; +#define timespec64 timespec + /* fake up iomap, (not) used in xfs_bmap.[ch] */ #define IOMAP_F_SHARED 0x04 #define xfs_bmbt_to_iomap(a, b, c, d) ((void) 0) diff --git a/libxfs/util.c b/libxfs/util.c index 69110076d..b6cc4e2c6 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -294,8 +294,8 @@ libxfs_ialloc( VFS_I(ip)->i_version = 1; ip->i_d.di_flags2 = pip ? 0 : xfs_flags2diflags2(ip, fsx->fsx_xflags); - ip->i_d.di_crtime.t_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec; - ip->i_d.di_crtime.t_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec; + ip->i_d.di_crtime.tv_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec; + ip->i_d.di_crtime.tv_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec; ip->i_d.di_cowextsize = pip ? 0 : fsx->fsx_cowextsize; } diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c index 4859b739a..a95e2e152 100644 --- a/libxfs/xfs_inode_buf.c +++ b/libxfs/xfs_inode_buf.c @@ -252,8 +252,8 @@ xfs_inode_from_disk( if (to->di_version == 3) { inode_set_iversion_queried(inode, be64_to_cpu(from->di_changecount)); - to->di_crtime.t_sec = be32_to_cpu(from->di_crtime.t_sec); - to->di_crtime.t_nsec = be32_to_cpu(from->di_crtime.t_nsec); + to->di_crtime.tv_sec = be32_to_cpu(from->di_crtime.t_sec); + to->di_crtime.tv_nsec = be32_to_cpu(from->di_crtime.t_nsec); to->di_flags2 = be64_to_cpu(from->di_flags2); to->di_cowextsize = be32_to_cpu(from->di_cowextsize); } @@ -302,8 +302,8 @@ xfs_inode_to_disk( if (from->di_version == 3) { to->di_changecount = cpu_to_be64(inode_peek_iversion(inode)); - to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.t_sec); - to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.t_nsec); + to->di_crtime.t_sec = cpu_to_be32(from->di_crtime.tv_sec); + to->di_crtime.t_nsec = cpu_to_be32(from->di_crtime.tv_nsec); to->di_flags2 = cpu_to_be64(from->di_flags2); to->di_cowextsize = cpu_to_be32(from->di_cowextsize); to->di_ino = cpu_to_be64(ip->i_ino); diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h index ab0f84165..c9ac69c82 100644 --- a/libxfs/xfs_inode_buf.h +++ b/libxfs/xfs_inode_buf.h @@ -37,7 +37,7 @@ struct xfs_icdinode { uint64_t di_flags2; /* more random flags */ uint32_t di_cowextsize; /* basic cow extent size for file */ - xfs_ictimestamp_t di_crtime; /* time created */ + struct timespec64 di_crtime; /* time created */ }; /* diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c index 7fa0c184a..f53b4c8df 100644 --- a/libxfs/xfs_trans_inode.c +++ b/libxfs/xfs_trans_inode.c @@ -52,7 +52,7 @@ xfs_trans_ichgtime( int flags) { struct inode *inode = VFS_I(ip); - struct timespec64 tv; + struct timespec64 tv; ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); @@ -63,10 +63,8 @@ xfs_trans_ichgtime( inode->i_mtime = tv; if (flags & XFS_ICHGTIME_CHG) inode->i_ctime = tv; - if (flags & XFS_ICHGTIME_CREATE) { - ip->i_d.di_crtime.t_sec = (int32_t)tv.tv_sec; - ip->i_d.di_crtime.t_nsec = (int32_t)tv.tv_nsec; - } + if (flags & XFS_ICHGTIME_CREATE) + ip->i_d.di_crtime = tv; } /* -- 2.47.2