[PATCH 04/11] fs: delay the actual timestamp updates in inode_update_timestamps
Christoph Hellwig
hch at lst.de
Mon Dec 22 16:37:47 PST 2025
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 at lst.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
More information about the linux-mtd
mailing list