public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: cem@kernel.org
To: linux-xfs@vger.kernel.org
Subject: [PATCH 21/35] xfs: convert to new timestamp accessors
Date: Thu, 15 Feb 2024 13:08:33 +0100	[thread overview]
Message-ID: <20240215120907.1542854-22-cem@kernel.org> (raw)
In-Reply-To: <20240215120907.1542854-1-cem@kernel.org>

From: Jeff Layton <jlayton@kernel.org>

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      | 74 ++++++++++++++++++++++++++++++++++++++--
 libxfs/util.c            |  2 +-
 libxfs/xfs_inode_buf.c   | 10 +++---
 libxfs/xfs_rtbitmap.c    |  6 +++-
 libxfs/xfs_trans_inode.c |  2 +-
 mkfs/proto.c             |  2 +-
 6 files changed, 86 insertions(+), 10 deletions(-)

diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index 986815e5c..a351bb0d9 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -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;
diff --git a/libxfs/util.c b/libxfs/util.c
index 8f79b0cd1..8517bfb64 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -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;
 	}
 
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index fccab4193..74a1bd227 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -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);
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index c635e8c2e..9a8bd93b7 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -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;
diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
index ca8e82376..c171a525c 100644
--- a/libxfs/xfs_trans_inode.c
+++ b/libxfs/xfs_trans_inode.c
@@ -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)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index ea31cfe5c..e9c633ed3 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -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;
-- 
2.43.0


  parent reply	other threads:[~2024-02-15 12:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 12:08 [PATCH 00/35] xfsprogs: libxfs-sync for 6.7 cem
2024-02-15 12:08 ` [PATCH 01/35] xfs: bump max fsgeom struct version cem
2024-02-15 12:08 ` [PATCH 02/35] xfs: hoist freeing of rt data fork extent mappings cem
2024-02-15 12:08 ` [PATCH 03/35] xfs: fix units conversion error in xfs_bmap_del_extent_delay cem
2024-02-15 12:08 ` [PATCH 04/35] xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h cem
2024-02-15 12:08 ` [PATCH 05/35] xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator cem
2024-02-15 12:08 ` [PATCH 06/35] xfs: convert rt bitmap/summary block numbers to xfs_fileoff_t cem
2024-02-15 12:08 ` [PATCH 07/35] xfs: convert rt bitmap extent lengths to xfs_rtbxlen_t cem
2024-02-15 12:08 ` [PATCH 08/35] xfs: rename xfs_verify_rtext to xfs_verify_rtbext cem
2024-02-15 12:08 ` [PATCH 09/35] xfs: convert rt extent numbers to xfs_rtxnum_t cem
2024-02-15 12:08 ` [PATCH 10/35] xfs: create a helper to convert rtextents to rtblocks cem
2024-02-15 12:08 ` [PATCH 11/35] xfs: create a helper to compute leftovers of realtime extents cem
2024-02-15 12:08 ` [PATCH 12/35] xfs: create a helper to convert extlen to rtextlen cem
2024-02-15 12:08 ` [PATCH 13/35] xfs: create helpers to convert rt block numbers to rt extent numbers cem
2024-02-15 12:08 ` [PATCH 14/35] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls cem
2024-02-15 12:08 ` [PATCH 15/35] xfs: create rt extent rounding helpers for realtime extent blocks cem
2024-02-15 12:08 ` [PATCH 16/35] xfs: use shifting and masking when converting rt extents, if possible cem
2024-02-15 12:08 ` [PATCH 17/35] xfs: convert the rtbitmap block and bit macros to static inline functions cem
2024-02-15 12:08 ` [PATCH 18/35] xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macros cem
2024-02-15 12:08 ` [PATCH 19/35] xfs: convert open-coded xfs_rtword_t pointer accesses to helper cem
2024-02-15 12:08 ` [PATCH 20/35] xfs: convert rt summary macros to helpers cem
2024-02-15 12:08 ` cem [this message]
2024-02-15 12:08 ` [PATCH 22/35] xfs: create helpers for rtbitmap block/wordcount computations cem
2024-02-15 12:08 ` [PATCH 23/35] xfs: create a helper to handle logging parts of rt bitmap/summary blocks cem
2024-02-15 12:08 ` [PATCH 24/35] xfs: use accessor functions for bitmap words cem
2024-02-15 12:08 ` [PATCH 25/35] xfs: create helpers for rtsummary block/wordcount computations cem
2024-02-15 12:08 ` [PATCH 26/35] xfs: use accessor functions for summary info words cem
2024-02-15 12:08 ` [PATCH 27/35] xfs: consolidate realtime allocation arguments cem
2024-02-15 12:08 ` [PATCH 28/35] xfs: cache last bitmap block in realtime allocator cem
2024-02-15 12:08 ` [PATCH 29/35] xfs: simplify xfs_rtbuf_get calling conventions cem
2024-02-15 12:08 ` [PATCH 30/35] xfs: simplify rt bitmap/summary block accessor functions cem
2024-02-15 12:08 ` [PATCH 31/35] xfs: invert the realtime summary cache cem
2024-02-15 12:08 ` [PATCH 32/35] xfs: factor out xfs_defer_pending_abort cem
2024-02-15 12:08 ` [PATCH 33/35] xfs: abort intent items when recovery intents fail cem
2024-02-15 12:08 ` [PATCH 34/35] xfs: fix internal error from AGFL exhaustion cem
2024-02-15 12:08 ` [PATCH 35/35] xfs: inode recovery does not validate the recovered inode cem
2024-02-16  7:11 ` [PATCH 00/35] xfsprogs: libxfs-sync for 6.7 Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240215120907.1542854-22-cem@kernel.org \
    --to=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox