f0371a1b16
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
179 lines
5.5 KiB
Diff
179 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Brian Behlendorf <behlendorf1@llnl.gov>
|
|
Date: Sun, 12 Aug 2018 18:22:54 -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>
|
|
|
|
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
|
|
---
|
|
config/kernel-inode-times.m4 | 25 +++++++++++++++++++++++++
|
|
config/spl-build.m4 | 1 +
|
|
include/sys/condvar.h | 1 +
|
|
include/sys/time.h | 25 +++++++++++++++++++------
|
|
include/sys/types.h | 3 ---
|
|
include/sys/vnode.h | 6 +++---
|
|
6 files changed, 49 insertions(+), 12 deletions(-)
|
|
create mode 100644 config/kernel-inode-times.m4
|
|
|
|
diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4
|
|
new file mode 100644
|
|
index 0000000..3a6acd8
|
|
--- /dev/null
|
|
+++ b/config/kernel-inode-times.m4
|
|
@@ -0,0 +1,25 @@
|
|
+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"
|
|
+])
|
|
diff --git a/config/spl-build.m4 b/config/spl-build.m4
|
|
index 5c6c02a..0dc5be8 100644
|
|
--- a/config/spl-build.m4
|
|
+++ b/config/spl-build.m4
|
|
@@ -43,6 +43,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
|
|
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
|
|
diff --git a/include/sys/condvar.h b/include/sys/condvar.h
|
|
index 5fcc906..ce3149a 100644
|
|
--- a/include/sys/condvar.h
|
|
+++ b/include/sys/condvar.h
|
|
@@ -31,6 +31,7 @@
|
|
#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
|
|
diff --git a/include/sys/time.h b/include/sys/time.h
|
|
index ddda6de..59557af 100644
|
|
--- a/include/sys/time.h
|
|
+++ b/include/sys/time.h
|
|
@@ -52,15 +52,28 @@
|
|
#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
|
|
@@ -74,9 +87,9 @@ gethrestime_sec(void)
|
|
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 */
|
|
diff --git a/include/sys/types.h b/include/sys/types.h
|
|
index 2fe63b7..b958462 100644
|
|
--- a/include/sys/types.h
|
|
+++ b/include/sys/types.h
|
|
@@ -49,9 +49,6 @@ typedef long long offset_t;
|
|
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;
|
|
diff --git a/include/sys/vnode.h b/include/sys/vnode.h
|
|
index 0ed4794..87f12d6 100644
|
|
--- a/include/sys/vnode.h
|
|
+++ b/include/sys/vnode.h
|
|
@@ -129,9 +129,9 @@ typedef struct vattr {
|
|
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 */
|
|
--
|
|
2.11.0
|
|
|