[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223003756.409543-5-hch@lst.de>
Date: Tue, 23 Dec 2025 09:37:47 +0900
From: Christoph Hellwig <hch@....de>
To: Christian Brauner <brauner@...nel.org>
Cc: Al Viro <viro@...iv.linux.org.uk>,
David Sterba <dsterba@...e.com>,
Jan Kara <jack@...e.cz>,
Mike Marshall <hubcap@...ibond.com>,
Martin Brandenburg <martin@...ibond.com>,
Carlos Maiolino <cem@...nel.org>,
Stefan Roesch <shr@...com>,
Jeff Layton <jlayton@...nel.org>,
linux-kernel@...r.kernel.org,
linux-btrfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
gfs2@...ts.linux.dev,
io-uring@...r.kernel.org,
devel@...ts.orangefs.org,
linux-unionfs@...r.kernel.org,
linux-mtd@...ts.infradead.org,
linux-xfs@...r.kernel.org,
linux-nfs@...r.kernel.org
Subject: [PATCH 04/11] fs: delay the actual timestamp updates in inode_update_timestamps
Perform the actual updates of the inode timestamp at the very end of
inode_update_timestamps after finishing all checks. This prepares for
adding non-blocking timestamp updates where we might bail out instead of
performing this updates if the update would block.
Signed-off-by: Christoph Hellwig <hch@....de>
---
fs/inode.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 876641a6e478..19f50bdb6f7d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2109,10 +2109,8 @@ int inode_update_timestamps(struct inode *inode, int flags)
now = inode_set_ctime_current(inode);
if (!timespec64_equal(&now, &ctime))
updated |= S_CTIME;
- if (!timespec64_equal(&now, &mtime)) {
- inode_set_mtime_to_ts(inode, now);
+ if (!timespec64_equal(&now, &mtime))
updated |= S_MTIME;
- }
if (IS_I_VERSION(inode) && inode_maybe_inc_iversion(inode, updated))
updated |= S_VERSION;
} else {
@@ -2122,11 +2120,14 @@ int inode_update_timestamps(struct inode *inode, int flags)
if (flags & S_ATIME) {
struct timespec64 atime = inode_get_atime(inode);
- if (!timespec64_equal(&now, &atime)) {
- inode_set_atime_to_ts(inode, now);
+ if (!timespec64_equal(&now, &atime))
updated |= S_ATIME;
- }
}
+
+ if (updated & S_MTIME)
+ inode_set_mtime_to_ts(inode, now);
+ if (updated & S_ATIME)
+ inode_set_atime_to_ts(inode, now);
return updated;
}
EXPORT_SYMBOL(inode_update_timestamps);
--
2.47.3
Powered by blists - more mailing lists