Commit e44df266 authored by Jeff Layton's avatar Jeff Layton Committed by Christian Brauner

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.
Acked-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Message-Id: <20230807-mgctime-v7-11-d1dec143a704@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent d48c3397
...@@ -62,12 +62,12 @@ xfs_trans_ichgtime( ...@@ -62,12 +62,12 @@ xfs_trans_ichgtime(
ASSERT(tp); ASSERT(tp);
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
tv = current_time(inode); /* If the mtime changes, then ctime must also change */
ASSERT(flags & XFS_ICHGTIME_CHG);
tv = inode_set_ctime_current(inode);
if (flags & XFS_ICHGTIME_MOD) if (flags & XFS_ICHGTIME_MOD)
inode->i_mtime = tv; inode->i_mtime = tv;
if (flags & XFS_ICHGTIME_CHG)
inode_set_ctime_to_ts(inode, tv);
if (flags & XFS_ICHGTIME_CREATE) if (flags & XFS_ICHGTIME_CREATE)
ip->i_crtime = tv; ip->i_crtime = tv;
} }
......
...@@ -573,10 +573,10 @@ xfs_vn_getattr( ...@@ -573,10 +573,10 @@ xfs_vn_getattr(
stat->gid = vfsgid_into_kgid(vfsgid); stat->gid = vfsgid_into_kgid(vfsgid);
stat->ino = ip->i_ino; stat->ino = ip->i_ino;
stat->atime = inode->i_atime; stat->atime = inode->i_atime;
stat->mtime = inode->i_mtime;
stat->ctime = inode_get_ctime(inode);
stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks);
fill_mg_cmtime(stat, request_mask, inode);
if (xfs_has_v3inodes(mp)) { if (xfs_has_v3inodes(mp)) {
if (request_mask & STATX_BTIME) { if (request_mask & STATX_BTIME) {
stat->result_mask |= STATX_BTIME; stat->result_mask |= STATX_BTIME;
...@@ -917,7 +917,7 @@ xfs_setattr_size( ...@@ -917,7 +917,7 @@ xfs_setattr_size(
if (newsize != oldsize && if (newsize != oldsize &&
!(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {
iattr->ia_ctime = iattr->ia_mtime = iattr->ia_ctime = iattr->ia_mtime =
current_time(inode); current_mgtime(inode);
iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;
} }
......
...@@ -2009,7 +2009,7 @@ static struct file_system_type xfs_fs_type = { ...@@ -2009,7 +2009,7 @@ static struct file_system_type xfs_fs_type = {
.init_fs_context = xfs_init_fs_context, .init_fs_context = xfs_init_fs_context,
.parameters = xfs_fs_parameters, .parameters = xfs_fs_parameters,
.kill_sb = kill_block_super, .kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME,
}; };
MODULE_ALIAS_FS("xfs"); MODULE_ALIAS_FS("xfs");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment