Skip to content

Commit

Permalink
xfs: have xfs_vn_update_time gets its own timestamp
Browse files Browse the repository at this point in the history
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: Jeff Layton <[email protected]>
Acked-by: "Darrick J. Wong" <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
jtlayton authored and brauner committed Aug 11, 2023
1 parent 6f4aaee commit 51b0f3e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fs/xfs/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,14 +1029,15 @@ 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);
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);

Expand All @@ -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);
Expand Down

0 comments on commit 51b0f3e

Please sign in to comment.