summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-01-08 15:19:05 +0100
committerChristian Brauner <brauner@kernel.org>2026-01-12 14:01:32 +0100
commit761475268fa8e322fe6b80bcf557dc65517df71e (patch)
tree5dbbc9ed2ead8ea6e155b752de12129e58e8e162 /fs/xfs
parent1cbc822816758b2678e94800ce8eecc7b706fb84 (diff)
fs: refactor ->update_time handling
Pass the type of update (atime vs c/mtime plus version) as an enum instead of a set of flags that caused all kinds of confusion. Because inode_update_timestamps now can't return a modified version of those flags, return the I_DIRTY_* flags needed to persist the update, which is what the main caller in generic_update_time wants anyway, and which is suitable for the other callers that only want to know if an update happened. The whole update_time path keeps the flags argument, which will be used to support non-blocking updates soon even if it is unused, and (the slightly renamed) inode_update_time also gains the possibility to return a negative errno to support this. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260108141934.2052404-6-hch@lst.de Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_iops.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 9dedb54e3cb0..d9eae1af14a8 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1184,21 +1184,21 @@ xfs_vn_setattr(
STATIC int
xfs_vn_update_time(
struct inode *inode,
- int flags)
+ enum fs_update_time type,
+ unsigned int flags)
{
struct xfs_inode *ip = XFS_I(inode);
struct xfs_mount *mp = ip->i_mount;
int log_flags = XFS_ILOG_TIMESTAMP;
struct xfs_trans *tp;
int error;
- struct timespec64 now;
trace_xfs_update_time(ip);
if (inode->i_sb->s_flags & SB_LAZYTIME) {
- if (!((flags & S_VERSION) &&
- inode_maybe_inc_iversion(inode, false)))
- return generic_update_time(inode, flags);
+ if (type == FS_UPD_ATIME ||
+ !inode_maybe_inc_iversion(inode, false))
+ return generic_update_time(inode, type, flags);
/* Capture the iversion update that just occurred */
log_flags |= XFS_ILOG_CORE;
@@ -1209,16 +1209,10 @@ xfs_vn_update_time(
return error;
xfs_ilock(ip, XFS_ILOCK_EXCL);
- if (flags & (S_CTIME|S_MTIME))
- now = inode_set_ctime_current(inode);
+ if (type == FS_UPD_ATIME)
+ inode_set_atime_to_ts(inode, current_time(inode));
else
- now = current_time(inode);
-
- if (flags & S_MTIME)
- inode_set_mtime_to_ts(inode, now);
- if (flags & S_ATIME)
- inode_set_atime_to_ts(inode, now);
-
+ inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, log_flags);
return xfs_trans_commit(tp);