Skip to content

Commit 1cf7e83

Browse files
jtlaytonbrauner
authored andcommitted
xfs: switch to multigrain timestamps
Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Also, anytime the mtime changes, the ctime must also change, and those are now the only two options for xfs_trans_ichgtime. Have that function unconditionally bump the ctime, and ASSERT that XFS_ICHGTIME_CHG is always set. Finally, stop setting STATX_CHANGE_COOKIE in getattr, since the ctime should give us better semantics now. Reviewed-by: Josef Bacik <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Tested-by: Randy Dunlap <[email protected]> # documentation bits Signed-off-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent e3fad03 commit 1cf7e83

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

fs/xfs/libxfs/xfs_trans_inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ xfs_trans_ichgtime(
6262
ASSERT(tp);
6363
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
6464

65-
tv = current_time(inode);
65+
/* If the mtime changes, then ctime must also change */
66+
ASSERT(flags & XFS_ICHGTIME_CHG);
6667

68+
tv = inode_set_ctime_current(inode);
6769
if (flags & XFS_ICHGTIME_MOD)
6870
inode_set_mtime_to_ts(inode, tv);
69-
if (flags & XFS_ICHGTIME_CHG)
70-
inode_set_ctime_to_ts(inode, tv);
7171
if (flags & XFS_ICHGTIME_ACCESS)
7272
inode_set_atime_to_ts(inode, tv);
7373
if (flags & XFS_ICHGTIME_CREATE)

fs/xfs/xfs_iops.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,9 @@ xfs_vn_getattr(
597597
stat->gid = vfsgid_into_kgid(vfsgid);
598598
stat->ino = ip->i_ino;
599599
stat->atime = inode_get_atime(inode);
600-
stat->mtime = inode_get_mtime(inode);
601-
stat->ctime = inode_get_ctime(inode);
600+
601+
fill_mg_cmtime(stat, request_mask, inode);
602+
602603
stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
603604

604605
if (xfs_has_v3inodes(mp)) {
@@ -608,11 +609,6 @@ xfs_vn_getattr(
608609
}
609610
}
610611

611-
if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) {
612-
stat->change_cookie = inode_query_iversion(inode);
613-
stat->result_mask |= STATX_CHANGE_COOKIE;
614-
}
615-
616612
/*
617613
* Note: If you add another clause to set an attribute flag, please
618614
* update attributes_mask below.

fs/xfs/xfs_super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ static struct file_system_type xfs_fs_type = {
20522052
.init_fs_context = xfs_init_fs_context,
20532053
.parameters = xfs_fs_parameters,
20542054
.kill_sb = xfs_kill_sb,
2055-
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
2055+
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME,
20562056
};
20572057
MODULE_ALIAS_FS("xfs");
20582058

0 commit comments

Comments
 (0)