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>
--- /dev/null
+dnl #
+dnl # 4.18 API change
+dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_INODE_TIMES], [
+ AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
+ tmp_flags="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="-Werror"
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ struct inode ip;
+ struct timespec ts;
+
+ memset(&ip, 0, sizeof(ip));
+ ts = ip.i_mtime;
+ ],[
+ AC_MSG_RESULT(no)
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_INODE_TIMESPEC64_TIMES, 1,
+ [inode->i_*time's are timespec64])
+ ])
+ EXTRA_KCFLAGS="$tmp_flags"
+])
SPL_AC_2ARGS_VFS_GETATTR
SPL_AC_USLEEP_RANGE
SPL_AC_KMEM_CACHE_ALLOCFLAGS
+ SPL_AC_KERNEL_INODE_TIMES
SPL_AC_WAIT_ON_BIT
SPL_AC_INODE_LOCK
SPL_AC_GROUP_INFO_GID
#include <sys/kmem.h>
#include <sys/mutex.h>
#include <sys/callo.h>
+#include <sys/time.h>
/*
* The kcondvar_t struct is protected by mutex taken externally before
#define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
#define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC))
+typedef longlong_t hrtime_t;
+typedef struct timespec timespec_t;
+
static const int hz = HZ;
#define TIMESPEC_OVERFLOW(ts) \
((ts)->tv_sec < TIME_MIN || (ts)->tv_sec > TIME_MAX)
+#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+typedef struct timespec64 inode_timespec_t;
+#else
+typedef struct timespec inode_timespec_t;
+#endif
+
static inline void
-gethrestime(timestruc_t *now)
-{
- *now = current_kernel_time();
+gethrestime(inode_timespec_t *ts)
+ {
+#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+ *ts = current_kernel_time64();
+#else
+ *ts = current_kernel_time();
+#endif
}
static inline time_t
static inline hrtime_t
gethrtime(void)
{
- struct timespec now;
- getrawmonotonic(&now);
- return (((hrtime_t)now.tv_sec * NSEC_PER_SEC) + now.tv_nsec);
+ struct timespec ts;
+ getrawmonotonic(&ts);
+ return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
}
#endif /* _SPL_TIME_H */
typedef struct task_struct kthread_t;
typedef struct task_struct proc_t;
typedef short pri_t;
-typedef struct timespec timestruc_t; /* definition per SVr4 */
-typedef struct timespec timespec_t;
-typedef longlong_t hrtime_t;
typedef unsigned short ushort_t;
typedef u_longlong_t len_t;
typedef longlong_t diskaddr_t;
long va_nodeid; /* node # */
uint32_t va_nlink; /* # links */
uint64_t va_size; /* file size */
- struct timespec va_atime; /* last acc */
- struct timespec va_mtime; /* last mod */
- struct timespec va_ctime; /* last chg */
+ inode_timespec_t va_atime; /* last acc */
+ inode_timespec_t va_mtime; /* last mod */
+ inode_timespec_t va_ctime; /* last chg */
dev_t va_rdev; /* dev */
uint64_t va_nblocks; /* space used */
uint32_t va_blksize; /* block size */