diff options
author | Nikolay Borisov <[email protected]> | 2016-09-12 22:35:56 +0300 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-13 12:00:18 -0700 |
commit | 87f9371aefca857e7091dfdee3ec2d36b0de54c4 (patch) | |
tree | 8769eb3e29dd3fa77ca59e4552201f8e4ab1f355 /module/zfs/zfs_vnops.c | |
parent | 9f5f0019ab3c03f59060d752b0be69290ec1abb9 (diff) |
Simplify time handling logic in zfs_settattr
Simplify time handling in zfs_setattr by mimicking the logic in
setattr_copy from the linux kernel. In order to achieve this
in the case when ZFS' log is being replayed it is necessary
to unconditionally set the ctime in zfs_replay_setattr.
Also use the timespec_trunc function when assigning values to the
generic inode struct. This is currently a noop since zfs sets
s_time_gran to 1, however in the future rules about precision might
change.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Chunwei Chen <[email protected]>
Signed-off-by: Nikolay Borisov <[email protected]>
Closes #4916
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r-- | module/zfs/zfs_vnops.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 82016af75..405b37c19 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -3001,7 +3001,6 @@ top: aclp = NULL; } - if ((mask & ATTR_ATIME) || zp->z_atime_dirty) { zp->z_atime_dirty = 0; ZFS_TIME_ENCODE(&ip->i_atime, atime); @@ -3011,29 +3010,27 @@ top: if (mask & ATTR_MTIME) { ZFS_TIME_ENCODE(&vap->va_mtime, mtime); + ZTOI(zp)->i_mtime = timespec_trunc(vap->va_mtime, + ZTOI(zp)->i_sb->s_time_gran); + SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zsb), NULL, mtime, sizeof (mtime)); } - /* XXX - shouldn't this be done *before* the ATIME/MTIME checks? */ - if (mask & ATTR_SIZE && !(mask & ATTR_MTIME)) { - SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zsb), - NULL, mtime, sizeof (mtime)); + if (mask & ATTR_CTIME) { + ZFS_TIME_ENCODE(&vap->va_ctime, ctime); + ZTOI(zp)->i_ctime = timespec_trunc(vap->va_ctime, + ZTOI(zp)->i_sb->s_time_gran); SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, - &ctime, sizeof (ctime)); - zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); - } else if (mask != 0) { - SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zsb), NULL, - &ctime, sizeof (ctime)); - zfs_tstamp_update_setup(zp, STATE_CHANGED, mtime, ctime); - if (attrzp) { - SA_ADD_BULK_ATTR(xattr_bulk, xattr_count, - SA_ZPL_CTIME(zsb), NULL, - &ctime, sizeof (ctime)); - zfs_tstamp_update_setup(attrzp, STATE_CHANGED, - mtime, ctime); - } + ctime, sizeof (ctime)); } + + if (attrzp && mask) { + SA_ADD_BULK_ATTR(xattr_bulk, xattr_count, + SA_ZPL_CTIME(zsb), NULL, &ctime, + sizeof (ctime)); + } + /* * Do this after setting timestamps to prevent timestamp * update from toggling bit |