Unverified Commit 51b0f3eb authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner
Browse files

xfs: have xfs_vn_update_time gets its own timestamp



In later patches we're going to drop the "now" parameter from the
update_time operation. Prepare XFS for this by reworking how it fetches
timestamps and sets them in the inode. Ensure that we update the ctime
even if only S_MTIME is set.

Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Acked-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Message-Id: <20230807-mgctime-v7-7-d1dec143a704@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 6f4aaee3
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -1029,7 +1029,7 @@ xfs_vn_setattr(
STATIC int
xfs_vn_update_time(
	struct inode		*inode,
	struct timespec64	*now,
	struct timespec64	*time,
	int			flags)
{
	struct xfs_inode	*ip = XFS_I(inode);
@@ -1037,6 +1037,7 @@ xfs_vn_update_time(
	int			log_flags = XFS_ILOG_TIMESTAMP;
	struct xfs_trans	*tp;
	int			error;
	struct timespec64	now;

	trace_xfs_update_time(ip);

@@ -1056,12 +1057,15 @@ xfs_vn_update_time(
		return error;

	xfs_ilock(ip, XFS_ILOCK_EXCL);
	if (flags & S_CTIME)
		inode_set_ctime_to_ts(inode, *now);
	if (flags & (S_CTIME|S_MTIME))
		now = inode_set_ctime_current(inode);
	else
		now = current_time(inode);

	if (flags & S_MTIME)
		inode->i_mtime = *now;
		inode->i_mtime = now;
	if (flags & S_ATIME)
		inode->i_atime = *now;
		inode->i_atime = now;

	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
	xfs_trans_log_inode(tp, ip, log_flags);