From: Jeff Layton <jlayton@kernel.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Darrick J. Wong" <djwong@kernel.org>, linux-xfs@vger.kernel.org
Subject: [PATCH 76/87] fs/xfs: convert to new inode {a,m}time accessors
Date: Thu, 28 Sep 2023 07:03:25 -0400 [thread overview]
Message-ID: <20230928110413.33032-75-jlayton@kernel.org> (raw)
In-Reply-To: <20230928110413.33032-1-jlayton@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/xfs/libxfs/xfs_inode_buf.c | 10 ++++++----
fs/xfs/libxfs/xfs_rtbitmap.c | 6 +++++-
fs/xfs/libxfs/xfs_trans_inode.c | 2 +-
fs/xfs/xfs_bmap_util.c | 7 ++++---
fs/xfs/xfs_inode.c | 4 ++--
fs/xfs/xfs_inode_item.c | 4 ++--
fs/xfs/xfs_iops.c | 8 ++++----
fs/xfs/xfs_itable.c | 8 ++++----
fs/xfs/xfs_rtalloc.c | 30 ++++++++++++++++--------------
9 files changed, 44 insertions(+), 35 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index a35781577cad..543f3748c2a3 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -220,8 +220,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));
@@ -315,8 +317,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/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index fa180ab66b73..396648acb5be 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -970,6 +970,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;
@@ -999,7 +1000,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));
+ *((uint64_t *)&atime) = 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/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
index 6b2296ff248a..70e97ea6eee7 100644
--- a/fs/xfs/libxfs/xfs_trans_inode.c
+++ b/fs/xfs/libxfs/xfs_trans_inode.c
@@ -65,7 +65,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/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index fcefab687285..40e0a1f1f753 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1644,7 +1644,7 @@ xfs_swap_extents(
uint64_t f;
int resblks = 0;
unsigned int flags = 0;
- struct timespec64 ctime;
+ struct timespec64 ctime, mtime;
/*
* Lock the inodes against other IO, page faults and truncate to
@@ -1758,10 +1758,11 @@ xfs_swap_extents(
* under it.
*/
ctime = inode_get_ctime(VFS_I(ip));
+ mtime = inode_get_mtime(VFS_I(ip));
if ((sbp->bs_ctime.tv_sec != ctime.tv_sec) ||
(sbp->bs_ctime.tv_nsec != ctime.tv_nsec) ||
- (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
- (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
+ (sbp->bs_mtime.tv_sec != mtime.tv_sec) ||
+ (sbp->bs_mtime.tv_nsec != mtime.tv_nsec)) {
error = -EBUSY;
goto out_trans_cancel;
}
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index f94f7b374041..e7600f6d3dc0 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -844,8 +844,8 @@ xfs_init_new_inode(
ASSERT(ip->i_nblocks == 0);
tv = inode_set_ctime_current(inode);
- inode->i_mtime = tv;
- inode->i_atime = tv;
+ inode_set_mtime_to_ts(inode, tv);
+ inode_set_atime_to_ts(inode, tv);
ip->i_extsize = 0;
ip->i_diflags = 0;
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 127b2410eb20..17c51804f9c6 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -526,8 +526,8 @@ xfs_inode_to_log_dinode(
to->di_projid_hi = ip->i_projid >> 16;
memset(to->di_pad3, 0, sizeof(to->di_pad3));
- to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode->i_atime);
- to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode->i_mtime);
+ to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode_get_atime(inode));
+ to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode_get_mtime(inode));
to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode_get_ctime(inode));
to->di_nlink = inode->i_nlink;
to->di_gen = inode->i_generation;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 1c1e6171209d..687eff5d9e16 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -572,8 +572,8 @@ xfs_vn_getattr(
stat->uid = vfsuid_into_kuid(vfsuid);
stat->gid = vfsgid_into_kgid(vfsgid);
stat->ino = ip->i_ino;
- stat->atime = inode->i_atime;
- stat->mtime = inode->i_mtime;
+ stat->atime = inode_get_atime(inode);
+ stat->mtime = inode_get_mtime(inode);
stat->ctime = inode_get_ctime(inode);
stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
@@ -1062,9 +1062,9 @@ xfs_vn_update_time(
now = current_time(inode);
if (flags & S_MTIME)
- inode->i_mtime = now;
+ inode_set_mtime_to_ts(inode, now);
if (flags & S_ATIME)
- inode->i_atime = now;
+ inode_set_atime_to_ts(inode, now);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, log_flags);
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index ccf0c4ff4490..38f5a2be302f 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -105,10 +105,10 @@ xfs_bulkstat_one_int(
buf->bs_size = ip->i_disk_size;
buf->bs_nlink = inode->i_nlink;
- buf->bs_atime = inode->i_atime.tv_sec;
- buf->bs_atime_nsec = inode->i_atime.tv_nsec;
- buf->bs_mtime = inode->i_mtime.tv_sec;
- buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
+ buf->bs_atime = inode_get_atime(inode).tv_sec;
+ buf->bs_atime_nsec = inode_get_atime(inode).tv_nsec;
+ buf->bs_mtime = inode_get_mtime(inode).tv_sec;
+ buf->bs_mtime_nsec = inode_get_mtime(inode).tv_nsec;
buf->bs_ctime = inode_get_ctime(inode).tv_sec;
buf->bs_ctime_nsec = inode_get_ctime(inode).tv_nsec;
buf->bs_gen = inode->i_generation;
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 16534e9873f6..2e1a4e5cd03d 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1420,25 +1420,26 @@ xfs_rtunmount_inodes(
*/
int /* error */
xfs_rtpick_extent(
- xfs_mount_t *mp, /* file system mount point */
- xfs_trans_t *tp, /* transaction pointer */
- xfs_extlen_t len, /* allocation length (rtextents) */
- xfs_rtblock_t *pick) /* result rt extent */
-{
- xfs_rtblock_t b; /* result block */
- int log2; /* log of sequence number */
- uint64_t resid; /* residual after log removed */
- uint64_t seq; /* sequence number of file creation */
- uint64_t *seqp; /* pointer to seqno in inode */
+ xfs_mount_t *mp, /* file system mount point */
+ xfs_trans_t *tp, /* transaction pointer */
+ xfs_extlen_t len, /* allocation length (rtextents) */
+ xfs_rtblock_t *pick) /* result rt extent */
+ {
+ xfs_rtblock_t b; /* result block */
+ int log2; /* log of sequence number */
+ uint64_t resid; /* residual after log removed */
+ uint64_t seq; /* sequence number of file creation */
+ struct timespec64 ts; /* temporary timespec64 storage */
ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
- seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime;
if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM)) {
mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
- *seqp = 0;
+ seq = 0;
+ } else {
+ ts = inode_get_atime(VFS_I(mp->m_rbmip));
+ seq = (uint64_t)ts.tv_sec;
}
- seq = *seqp;
if ((log2 = xfs_highbit64(seq)) == -1)
b = 0;
else {
@@ -1450,7 +1451,8 @@ xfs_rtpick_extent(
if (b + len > mp->m_sb.sb_rextents)
b = mp->m_sb.sb_rextents - len;
}
- *seqp = seq + 1;
+ ts.tv_sec = (time64_t)seq + 1;
+ inode_set_atime_to_ts(VFS_I(mp->m_rbmip), ts);
xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
*pick = b;
return 0;
--
2.41.0
next prev parent reply other threads:[~2023-09-28 11:19 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 11:02 [PATCH 00/87] fs: new accessor methods for atime and mtime Jeff Layton
2023-09-28 11:02 ` [PATCH 02/87] fs: convert core infrastructure to new {a,m}time accessors Jeff Layton
2023-09-28 11:02 ` [PATCH 03/87] arch/powerpc/platforms/cell/spufs: convert to new inode " Jeff Layton
2023-09-28 11:02 ` [PATCH 04/87] arch/s390/hypfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 05/87] drivers/android: " Jeff Layton
2023-09-28 11:02 ` [PATCH 06/87] drivers/char: " Jeff Layton
2023-09-28 11:02 ` [PATCH 07/87] drivers/infiniband/hw/qib: " Jeff Layton
2023-09-28 11:02 ` [PATCH 08/87] drivers/misc/ibmasm: " Jeff Layton
2023-09-28 11:02 ` [PATCH 09/87] drivers/misc: " Jeff Layton
2023-09-28 11:02 ` [PATCH 10/87] drivers/platform/x86: " Jeff Layton
2023-09-28 12:34 ` Hans de Goede
2023-09-28 11:02 ` [PATCH 11/87] drivers/tty: " Jeff Layton
2023-09-28 12:13 ` Greg KH
2023-09-28 12:23 ` Jeff Layton
2023-09-28 11:02 ` [PATCH 12/87] drivers/usb/core: " Jeff Layton
2023-09-28 11:02 ` [PATCH 13/87] drivers/usb/gadget/function: " Jeff Layton
2023-09-28 11:02 ` [PATCH 14/87] drivers/usb/gadget/legacy: " Jeff Layton
2023-09-28 11:02 ` [PATCH 15/87] fs/9p: " Jeff Layton
2023-09-28 11:02 ` [PATCH 16/87] fs/adfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 17/87] fs/affs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 18/87] fs/afs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 19/87] fs/autofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 20/87] fs/befs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 21/87] fs/bfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 22/87] fs/btrfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 23/87] fs/ceph: " Jeff Layton
2023-09-28 11:02 ` [PATCH 24/87] fs/coda: " Jeff Layton
2023-09-28 11:02 ` [PATCH 25/87] fs/configfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 26/87] fs/cramfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 27/87] fs/debugfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 28/87] fs/devpts: " Jeff Layton
2023-09-28 11:02 ` [PATCH 29/87] fs/efivarfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 30/87] fs/efs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 31/87] fs/erofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 32/87] fs/exfat: " Jeff Layton
2023-09-28 11:02 ` [PATCH 33/87] fs/ext2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 34/87] fs/ext4: " Jeff Layton
2023-09-28 11:02 ` [PATCH 35/87] fs/f2fs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 36/87] fs/fat: " Jeff Layton
2023-09-28 11:02 ` [PATCH 37/87] fs/freevxfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 38/87] fs/fuse: " Jeff Layton
2023-09-28 11:02 ` [PATCH 39/87] fs/gfs2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 40/87] fs/hfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 41/87] fs/hfsplus: " Jeff Layton
2023-09-28 11:02 ` [PATCH 42/87] fs/hostfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 43/87] fs/hpfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 44/87] fs/hugetlbfs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 45/87] fs/isofs: " Jeff Layton
2023-09-28 11:02 ` [PATCH 46/87] fs/jffs2: " Jeff Layton
2023-09-28 11:02 ` [PATCH 47/87] fs/jfs: " Jeff Layton
2023-10-03 16:33 ` [Jfs-discussion] [PATCH 47/87] fs/jfs: convert to new inode {a, m}time accessors Dave Kleikamp
2023-09-28 11:02 ` [PATCH 48/87] fs/kernfs: convert to new inode {a,m}time accessors Jeff Layton
2023-09-28 11:02 ` [PATCH 49/87] fs/minix: " Jeff Layton
2023-09-28 11:02 ` [PATCH 50/87] fs/nfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 51/87] fs/nfsd: " Jeff Layton
2023-09-28 13:56 ` Chuck Lever
2023-09-28 14:09 ` Jeff Layton
2023-09-28 14:33 ` Chuck Lever
2023-09-28 11:03 ` [PATCH 52/87] fs/nilfs2: " Jeff Layton
2023-09-28 11:03 ` [PATCH 53/87] fs/ntfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 54/87] fs/ntfs3: " Jeff Layton
2023-09-28 11:03 ` [PATCH 55/87] fs/ocfs2: " Jeff Layton
2023-09-28 11:03 ` [PATCH 56/87] fs/omfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 57/87] fs/openpromfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 58/87] fs/orangefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 59/87] fs/overlayfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 60/87] fs/proc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 61/87] fs/pstore: " Jeff Layton
2023-09-28 11:03 ` [PATCH 62/87] fs/qnx4: " Jeff Layton
2023-09-28 12:41 ` Anders Larsen
2023-09-28 11:03 ` [PATCH 63/87] fs/qnx6: " Jeff Layton
2023-09-28 11:03 ` [PATCH 64/87] fs/ramfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 65/87] fs/reiserfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 66/87] fs/romfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 67/87] fs/smb/client: " Jeff Layton
2023-09-28 11:03 ` [PATCH 68/87] fs/smb/server: " Jeff Layton
2023-09-28 11:03 ` [PATCH 69/87] fs/squashfs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 70/87] fs/sysv: " Jeff Layton
2023-09-28 11:03 ` [PATCH 71/87] fs/tracefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 72/87] fs/ubifs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 73/87] fs/udf: " Jeff Layton
2023-09-28 11:03 ` [PATCH 74/87] fs/ufs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 75/87] fs/vboxsf: " Jeff Layton
2023-09-28 11:03 ` Jeff Layton [this message]
2023-09-28 11:03 ` [PATCH 77/87] fs/zonefs: " Jeff Layton
2023-09-28 11:03 ` [PATCH 78/87] ipc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 79/87] kernel/bpf: " Jeff Layton
2023-09-28 11:03 ` [PATCH 80/87] mm: " Jeff Layton
2023-09-28 11:03 ` [PATCH 81/87] net/sunrpc: " Jeff Layton
2023-09-28 11:03 ` [PATCH 82/87] security/apparmor: " Jeff Layton
2023-09-28 11:03 ` [PATCH 83/87] security/selinux: " Jeff Layton
2023-10-03 19:53 ` Paul Moore
2023-09-28 11:03 ` [PATCH 84/87] security: " Jeff Layton
2023-10-03 23:41 ` Paul Moore
2023-09-28 11:03 ` [PATCH 01/87] fs: new accessor methods for atime and mtime Jeff Layton
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=20230928110413.33032-75-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).