summarylogtreecommitdiffstats
path: root/upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch
diff options
context:
space:
mode:
Diffstat (limited to 'upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch')
-rw-r--r--upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch558
1 files changed, 558 insertions, 0 deletions
diff --git a/upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch b/upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch
new file mode 100644
index 000000000000..de6771975ccc
--- /dev/null
+++ b/upstream-9f64c1e-Linux-4.18-compat-inode-timespec_timespec64.patch
@@ -0,0 +1,558 @@
+From 9f64c1e8890fb4cd69c39a768afc633df404cd63 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Sun, 12 Aug 2018 18:22:03 -0400
+Subject: [PATCH] Linux 4.18 compat: inode timespec -> timespec64
+
+Commit torvalds/linux@95582b0 changes the inode i_atime, i_mtime,
+and i_ctime members form timespec's to timespec64's to make them
+2038 safe. As part of this change the current_time() function was
+also updated to return the timespec64 type.
+
+Resolve this issue by introducing a new inode_timespec_t type which
+is defined to match the timespec type used by the inode. It should
+be used when working with inode timestamps to ensure matching types.
+
+The timestruc_t type under Illumos was used in a similar fashion but
+was specified to always be a timespec_t. Rather than incorrectly
+define this type all timespec_t types have been replaced by the new
+inode_timespec_t type.
+
+Finally, the kernel and user space 'sys/time.h' headers were aligned
+with each other. They define as appropriate for the context several
+constants as macros and include static inline implementation of
+gethrestime(), gethrestime_sec(), and gethrtime().
+
+Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #7643
+Backported-by: Richard Yao <ryao@gentoo.org>
+---
+ config/kernel-current-time.m4 | 7 +++---
+ include/sys/dmu.h | 2 +-
+ include/sys/dmu_objset.h | 2 +-
+ include/sys/dsl_dir.h | 4 ++--
+ include/sys/spa_impl.h | 2 +-
+ include/sys/xvattr.h | 2 +-
+ include/sys/zfs_context.h | 9 +------
+ include/sys/zfs_znode.h | 33 ++++++++++++++++++-------
+ include/sys/zpl.h | 9 +++++++
+ lib/libspl/Makefile.am | 2 --
+ lib/libspl/gethrestime.c | 38 -----------------------------
+ lib/libspl/gethrtime.c | 45 -----------------------------------
+ lib/libspl/include/sys/time.h | 37 +++++++++++++++++++++-------
+ lib/libzpool/kernel.c | 4 ++--
+ module/zfs/dmu_objset.c | 2 +-
+ module/zfs/dsl_dir.c | 6 ++---
+ module/zfs/fm.c | 2 +-
+ module/zfs/zfs_ctldir.c | 2 +-
+ module/zfs/zfs_vnops.c | 4 ++--
+ module/zfs/zfs_znode.c | 4 ++--
+ module/zfs/zpl_inode.c | 5 ++--
+ 21 files changed, 88 insertions(+), 133 deletions(-)
+ delete mode 100644 lib/libspl/gethrestime.c
+ delete mode 100644 lib/libspl/gethrtime.c
+
+diff --git a/config/kernel-current-time.m4 b/config/kernel-current-time.m4
+index 2ede9ff38c4..c7d5c9b5200 100644
+--- a/config/kernel-current-time.m4
++++ b/config/kernel-current-time.m4
+@@ -1,15 +1,14 @@
+ dnl #
+ dnl # 4.9, current_time() added
++dnl # 4.18, return type changed from timespec to timespec64
+ dnl #
+ AC_DEFUN([ZFS_AC_KERNEL_CURRENT_TIME],
+ [AC_MSG_CHECKING([whether current_time() exists])
+ ZFS_LINUX_TRY_COMPILE_SYMBOL([
+ #include <linux/fs.h>
+ ], [
+- struct inode ip;
+- struct timespec now __attribute__ ((unused));
+-
+- now = current_time(&ip);
++ struct inode ip __attribute__ ((unused));
++ ip.i_atime = current_time(&ip);
+ ], [current_time], [fs/inode.c], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_CURRENT_TIME, 1, [current_time() exists])
+diff --git a/include/sys/dmu.h b/include/sys/dmu.h
+index bcdf7d646fb..755a90561ae 100644
+--- a/include/sys/dmu.h
++++ b/include/sys/dmu.h
+@@ -891,7 +891,7 @@ uint64_t dmu_objset_fsid_guid(objset_t *os);
+ /*
+ * Get the [cm]time for an objset's snapshot dir
+ */
+-timestruc_t dmu_objset_snap_cmtime(objset_t *os);
++inode_timespec_t dmu_objset_snap_cmtime(objset_t *os);
+
+ int dmu_objset_is_snapshot(objset_t *os);
+
+diff --git a/include/sys/dmu_objset.h b/include/sys/dmu_objset.h
+index a836e03722c..531e81d4d88 100644
+--- a/include/sys/dmu_objset.h
++++ b/include/sys/dmu_objset.h
+@@ -179,7 +179,7 @@ int dmu_objset_find_dp(struct dsl_pool *dp, uint64_t ddobj,
+ int func(struct dsl_pool *, struct dsl_dataset *, void *),
+ void *arg, int flags);
+ void dmu_objset_evict_dbufs(objset_t *os);
+-timestruc_t dmu_objset_snap_cmtime(objset_t *os);
++inode_timespec_t dmu_objset_snap_cmtime(objset_t *os);
+
+ /* called from dsl */
+ void dmu_objset_sync(objset_t *os, zio_t *zio, dmu_tx_t *tx);
+diff --git a/include/sys/dsl_dir.h b/include/sys/dsl_dir.h
+index 69b0b6a5355..80e83fdc4d3 100644
+--- a/include/sys/dsl_dir.h
++++ b/include/sys/dsl_dir.h
+@@ -103,7 +103,7 @@ struct dsl_dir {
+ /* Protected by dd_lock */
+ kmutex_t dd_lock;
+ list_t dd_props; /* list of dsl_prop_record_t's */
+- timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
++ inode_timespec_t dd_snap_cmtime; /* last snapshot namespace change */
+ uint64_t dd_origin_txg;
+
+ /* gross estimate of space used by in-flight tx's */
+@@ -159,7 +159,7 @@ boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
+ void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
+ uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
+ void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
+-timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
++inode_timespec_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
+ void dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value,
+ dmu_tx_t *tx);
+ void dsl_dir_zapify(dsl_dir_t *dd, dmu_tx_t *tx);
+diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h
+index b1e78c1d592..fa7490ace67 100644
+--- a/include/sys/spa_impl.h
++++ b/include/sys/spa_impl.h
+@@ -153,7 +153,7 @@ struct spa {
+ uint64_t spa_freeze_txg; /* freeze pool at this txg */
+ uint64_t spa_load_max_txg; /* best initial ub_txg */
+ uint64_t spa_claim_max_txg; /* highest claimed birth txg */
+- timespec_t spa_loaded_ts; /* 1st successful open time */
++ inode_timespec_t spa_loaded_ts; /* 1st successful open time */
+ objset_t *spa_meta_objset; /* copy of dp->dp_meta_objset */
+ kmutex_t spa_evicting_os_lock; /* Evicting objset list lock */
+ list_t spa_evicting_os_list; /* Objsets being evicted. */
+diff --git a/include/sys/xvattr.h b/include/sys/xvattr.h
+index 4779b632163..5d38927cd4b 100644
+--- a/include/sys/xvattr.h
++++ b/include/sys/xvattr.h
+@@ -47,7 +47,7 @@
+ * Structure of all optional attributes.
+ */
+ typedef struct xoptattr {
+- timestruc_t xoa_createtime; /* Create time of file */
++ inode_timespec_t xoa_createtime; /* Create time of file */
+ uint8_t xoa_archive;
+ uint8_t xoa_system;
+ uint8_t xoa_readonly;
+diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h
+index 4fe35342dee..68c58f95531 100644
+--- a/include/sys/zfs_context.h
++++ b/include/sys/zfs_context.h
+@@ -527,7 +527,7 @@ extern char *vn_dumpdir;
+ #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
+
+ typedef struct xoptattr {
+- timestruc_t xoa_createtime; /* Create time of file */
++ inode_timespec_t xoa_createtime; /* Create time of file */
+ uint8_t xoa_archive;
+ uint8_t xoa_system;
+ uint8_t xoa_readonly;
+@@ -640,13 +640,6 @@ extern void delay(clock_t ticks);
+ #define USEC_TO_TICK(usec) ((usec) / (MICROSEC / hz))
+ #define NSEC_TO_TICK(usec) ((usec) / (NANOSEC / hz))
+
+-#define gethrestime_sec() time(NULL)
+-#define gethrestime(t) \
+- do {\
+- (t)->tv_sec = gethrestime_sec();\
+- (t)->tv_nsec = 0;\
+- } while (0);
+-
+ #define max_ncpus 64
+ #define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN))
+
+diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
+index c292f03739e..26d1eb37557 100644
+--- a/include/sys/zfs_znode.h
++++ b/include/sys/zfs_znode.h
+@@ -270,19 +270,36 @@ typedef struct znode_hold {
+
+ extern unsigned int zfs_object_mutex_size;
+
+-/* Encode ZFS stored time values from a struct timespec */
++/*
++ * Encode ZFS stored time values from a struct timespec / struct timespec64.
++ */
+ #define ZFS_TIME_ENCODE(tp, stmp) \
+-{ \
++do { \
+ (stmp)[0] = (uint64_t)(tp)->tv_sec; \
+ (stmp)[1] = (uint64_t)(tp)->tv_nsec; \
+-}
++} while (0)
+
+-/* Decode ZFS stored time values to a struct timespec */
++#if defined(HAVE_INODE_TIMESPEC64_TIMES)
++/*
++ * Decode ZFS stored time values to a struct timespec64
++ * 4.18 and newer kernels.
++ */
+ #define ZFS_TIME_DECODE(tp, stmp) \
+-{ \
+- (tp)->tv_sec = (time_t)(stmp)[0]; \
+- (tp)->tv_nsec = (long)(stmp)[1]; \
+-}
++do { \
++ (tp)->tv_sec = (time64_t)(stmp)[0]; \
++ (tp)->tv_nsec = (long)(stmp)[1]; \
++} while (0)
++#else
++/*
++ * Decode ZFS stored time values to a struct timespec
++ * 4.17 and older kernels.
++ */
++#define ZFS_TIME_DECODE(tp, stmp) \
++do { \
++ (tp)->tv_sec = (time_t)(stmp)[0]; \
++ (tp)->tv_nsec = (long)(stmp)[1]; \
++} while (0)
++#endif /* HAVE_INODE_TIMESPEC64_TIMES */
+
+ /*
+ * Timestamp defines
+diff --git a/include/sys/zpl.h b/include/sys/zpl.h
+index 65ed4313603..e433fbc64ea 100644
+--- a/include/sys/zpl.h
++++ b/include/sys/zpl.h
+@@ -189,4 +189,13 @@ zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
+ }
+ #endif /* HAVE_VFS_ITERATE */
+
++/*
++ * Linux 4.18, inode times converted from timespec to timespec64.
++ */
++#if defined(HAVE_INODE_TIMESPEC64_TIMES)
++#define zpl_inode_timespec_trunc(ts, gran) timespec64_trunc(ts, gran)
++#else
++#define zpl_inode_timespec_trunc(ts, gran) timespec_trunc(ts, gran)
++#endif
++
+ #endif /* _SYS_ZPL_H */
+diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am
+index 59bc8ffb42f..a6e63cb8868 100644
+--- a/lib/libspl/Makefile.am
++++ b/lib/libspl/Makefile.am
+@@ -19,8 +19,6 @@ noinst_LTLIBRARIES = libspl.la
+
+ USER_C = \
+ getexecname.c \
+- gethrtime.c \
+- gethrestime.c \
+ getmntany.c \
+ list.c \
+ mkdirp.c \
+diff --git a/lib/libspl/gethrestime.c b/lib/libspl/gethrestime.c
+deleted file mode 100644
+index d37cc2d5994..00000000000
+--- a/lib/libspl/gethrestime.c
++++ /dev/null
+@@ -1,38 +0,0 @@
+-/*
+- * CDDL HEADER START
+- *
+- * The contents of this file are subject to the terms of the
+- * Common Development and Distribution License (the "License").
+- * You may not use this file except in compliance with the License.
+- *
+- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+- * or http://www.opensolaris.org/os/licensing.
+- * See the License for the specific language governing permissions
+- * and limitations under the License.
+- *
+- * When distributing Covered Code, include this CDDL HEADER in each
+- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+- * If applicable, add the following below this CDDL HEADER, with the
+- * fields enclosed by brackets "[]" replaced with your own identifying
+- * information: Portions Copyright [yyyy] [name of copyright owner]
+- *
+- * CDDL HEADER END
+- */
+-
+-/*
+- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+- * Use is subject to license terms.
+- */
+-
+-#include <time.h>
+-#include <sys/time.h>
+-
+-void
+-gethrestime(timestruc_t *ts)
+-{
+- struct timeval tv;
+-
+- gettimeofday(&tv, NULL);
+- ts->tv_sec = tv.tv_sec;
+- ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
+-}
+diff --git a/lib/libspl/gethrtime.c b/lib/libspl/gethrtime.c
+deleted file mode 100644
+index 95ceb18e119..00000000000
+--- a/lib/libspl/gethrtime.c
++++ /dev/null
+@@ -1,45 +0,0 @@
+-/*
+- * CDDL HEADER START
+- *
+- * The contents of this file are subject to the terms of the
+- * Common Development and Distribution License (the "License").
+- * You may not use this file except in compliance with the License.
+- *
+- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+- * or http://www.opensolaris.org/os/licensing.
+- * See the License for the specific language governing permissions
+- * and limitations under the License.
+- *
+- * When distributing Covered Code, include this CDDL HEADER in each
+- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+- * If applicable, add the following below this CDDL HEADER, with the
+- * fields enclosed by brackets "[]" replaced with your own identifying
+- * information: Portions Copyright [yyyy] [name of copyright owner]
+- *
+- * CDDL HEADER END
+- */
+-
+-/*
+- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+- * Use is subject to license terms.
+- */
+-
+-#include <time.h>
+-#include <sys/time.h>
+-#include <stdlib.h>
+-#include <stdio.h>
+-
+-hrtime_t
+-gethrtime(void)
+-{
+- struct timespec ts;
+- int rc;
+-
+- rc = clock_gettime(CLOCK_MONOTONIC, &ts);
+- if (rc) {
+- fprintf(stderr, "Error: clock_gettime() = %d\n", rc);
+- abort();
+- }
+-
+- return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec);
+-}
+diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h
+index dc645fa5c37..04b3ba87bd3 100644
+--- a/lib/libspl/include/sys/time.h
++++ b/lib/libspl/include/sys/time.h
+@@ -27,8 +27,9 @@
+ #ifndef _LIBSPL_SYS_TIME_H
+ #define _LIBSPL_SYS_TIME_H
+
+-#include_next <sys/time.h>
++#include <time.h>
+ #include <sys/types.h>
++#include_next <sys/time.h>
+
+ #ifndef SEC
+ #define SEC 1
+@@ -70,13 +71,33 @@
+ #define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC))
+ #endif
+
+-
+ typedef long long hrtime_t;
+-typedef struct timespec timestruc_t;
+-typedef struct timespec timespec_t;
+-
+-
+-extern hrtime_t gethrtime(void);
+-extern void gethrestime(timestruc_t *);
++typedef struct timespec timespec_t;
++typedef struct timespec inode_timespec_t;
++
++static inline void
++gethrestime(inode_timespec_t *ts)
++{
++ struct timeval tv;
++ (void) gettimeofday(&tv, NULL);
++ ts->tv_sec = tv.tv_sec;
++ ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
++}
++
++static inline time_t
++gethrestime_sec(void)
++{
++ struct timeval tv;
++ (void) gettimeofday(&tv, NULL);
++ return (tv.tv_sec);
++}
++
++static inline hrtime_t
++gethrtime(void)
++{
++ struct timespec ts;
++ (void) clock_gettime(CLOCK_MONOTONIC, &ts);
++ return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec);
++}
+
+ #endif /* _LIBSPL_SYS_TIME_H */
+diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c
+index e67d13c9265..3ea8778b1dc 100644
+--- a/lib/libzpool/kernel.c
++++ b/lib/libzpool/kernel.c
+@@ -498,7 +498,7 @@ cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
+ {
+ int error;
+ struct timeval tv;
+- timestruc_t ts;
++ struct timespec ts;
+ clock_t delta;
+
+ ASSERT3U(cv->cv_magic, ==, CV_MAGIC);
+@@ -536,7 +536,7 @@ cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res,
+ {
+ int error;
+ struct timeval tv;
+- timestruc_t ts;
++ struct timespec ts;
+ hrtime_t delta;
+
+ ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE);
+diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
+index 3425d542f98..449ebedfa16 100644
+--- a/module/zfs/dmu_objset.c
++++ b/module/zfs/dmu_objset.c
+@@ -860,7 +860,7 @@ dmu_objset_evict_done(objset_t *os)
+ kmem_free(os, sizeof (objset_t));
+ }
+
+-timestruc_t
++inode_timespec_t
+ dmu_objset_snap_cmtime(objset_t *os)
+ {
+ return (dsl_dir_snap_cmtime(os->os_dsl_dataset->ds_dir));
+diff --git a/module/zfs/dsl_dir.c b/module/zfs/dsl_dir.c
+index a3ef5896a3f..deecf6bc53e 100644
+--- a/module/zfs/dsl_dir.c
++++ b/module/zfs/dsl_dir.c
+@@ -1975,10 +1975,10 @@ dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd,
+ return (0);
+ }
+
+-timestruc_t
++inode_timespec_t
+ dsl_dir_snap_cmtime(dsl_dir_t *dd)
+ {
+- timestruc_t t;
++ inode_timespec_t t;
+
+ mutex_enter(&dd->dd_lock);
+ t = dd->dd_snap_cmtime;
+@@ -1990,7 +1990,7 @@ dsl_dir_snap_cmtime(dsl_dir_t *dd)
+ void
+ dsl_dir_snap_cmtime_update(dsl_dir_t *dd)
+ {
+- timestruc_t t;
++ inode_timespec_t t;
+
+ gethrestime(&t);
+ mutex_enter(&dd->dd_lock);
+diff --git a/module/zfs/fm.c b/module/zfs/fm.c
+index cb148149376..9d26cc99eeb 100644
+--- a/module/zfs/fm.c
++++ b/module/zfs/fm.c
+@@ -508,8 +508,8 @@ zfs_zevent_insert(zevent_t *ev)
+ int
+ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
+ {
++ inode_timespec_t tv;
+ int64_t tv_array[2];
+- timestruc_t tv;
+ uint64_t eid;
+ size_t nvl_size = 0;
+ zevent_t *ev;
+diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c
+index 3b5fb196f1d..3ff2c101b67 100644
+--- a/module/zfs/zfs_ctldir.c
++++ b/module/zfs/zfs_ctldir.c
+@@ -451,7 +451,7 @@ static struct inode *
+ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id,
+ const struct file_operations *fops, const struct inode_operations *ops)
+ {
+- struct timespec now;
++ inode_timespec_t now;
+ struct inode *ip;
+ znode_t *zp;
+
+diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
+index 0d2b61a1c31..34ea751c320 100644
+--- a/module/zfs/zfs_vnops.c
++++ b/module/zfs/zfs_vnops.c
+@@ -3158,7 +3158,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr)
+
+ if (mask & (ATTR_MTIME | ATTR_SIZE)) {
+ ZFS_TIME_ENCODE(&vap->va_mtime, mtime);
+- ZTOI(zp)->i_mtime = timespec_trunc(vap->va_mtime,
++ ZTOI(zp)->i_mtime = zpl_inode_timespec_trunc(vap->va_mtime,
+ ZTOI(zp)->i_sb->s_time_gran);
+
+ SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL,
+@@ -3167,7 +3167,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr)
+
+ if (mask & (ATTR_CTIME | ATTR_SIZE)) {
+ ZFS_TIME_ENCODE(&vap->va_ctime, ctime);
+- ZTOI(zp)->i_ctime = timespec_trunc(vap->va_ctime,
++ ZTOI(zp)->i_ctime = zpl_inode_timespec_trunc(vap->va_ctime,
+ ZTOI(zp)->i_sb->s_time_gran);
+ SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL,
+ ctime, sizeof (ctime));
+diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
+index f508a248f0f..e222c791183 100644
+--- a/module/zfs/zfs_znode.c
++++ b/module/zfs/zfs_znode.c
+@@ -700,7 +700,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
+ uint64_t rdev = 0;
+ zfsvfs_t *zfsvfs = ZTOZSB(dzp);
+ dmu_buf_t *db;
+- timestruc_t now;
++ inode_timespec_t now;
+ uint64_t gen, obj;
+ int bonuslen;
+ int dnodesize;
+@@ -1349,7 +1349,7 @@ void
+ zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
+ uint64_t ctime[2])
+ {
+- timestruc_t now;
++ inode_timespec_t now;
+
+ gethrestime(&now);
+
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index 3b5643d0917..41b91cabcb9 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -384,9 +384,10 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
+ vap->va_mtime = ia->ia_mtime;
+ vap->va_ctime = ia->ia_ctime;
+
+- if (vap->va_mask & ATTR_ATIME)
+- ip->i_atime = timespec_trunc(ia->ia_atime,
++ if (vap->va_mask & ATTR_ATIME) {
++ ip->i_atime = zpl_inode_timespec_trunc(ia->ia_atime,
+ ip->i_sb->s_time_gran);
++ }
+
+ cookie = spl_fstrans_mark();
+ error = -zfs_setattr(ip, vap, 0, cr);