]> git.proxmox.com Git - mirror_spl.git/commitdiff
Linux 4.20 compat: Fix current_kernel_time()
authorTony Hutter <hutter2@llnl.gov>
Tue, 29 Jan 2019 05:09:28 +0000 (21:09 -0800)
committerTony Hutter <hutter2@llnl.gov>
Fri, 22 Feb 2019 17:47:27 +0000 (09:47 -0800)
current_kernel_time() is no longer provided in the 4.20 kernel.
Add a shim that calls the correct "get current time" function.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
config/kernel-current_kernel_time.m4 [new file with mode: 0644]
config/spl-build.m4
include/sys/time.h

diff --git a/config/kernel-current_kernel_time.m4 b/config/kernel-current_kernel_time.m4
new file mode 100644 (file)
index 0000000..860e4d5
--- /dev/null
@@ -0,0 +1,16 @@
+dnl #
+dnl # 4.20: Kernel removes current_kernel_time()
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_CURRENT_KERNEL_TIME],
+       [AC_MSG_CHECKING([whether current_kernel_time() exists])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/ktime.h>
+       ], [
+               struct timespec t __attribute__ ((unused)) = current_kernel_time();
+       ], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_KERNEL_CURRENT_TIME, 1, [current_kernel_time() exists])
+       ], [
+               AC_MSG_RESULT(no)
+       ])
+])
index 6d51187dd711fc29f9d29d573d63fe9d311435c4..f8b873238f2631ddf52e71c132595f892e53fd6d 100644 (file)
@@ -57,6 +57,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
        SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
        SPL_AC_KERNEL_TIMESPEC_SUB
+       SPL_AC_KERNEL_CURRENT_KERNEL_TIME
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
index 461e7317d711cda291a33fad143fa99f5dc093da..5328a0a09f115635306766cab615a83a5e29f673 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/module.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <sys/types.h>
 #include <sys/timer.h>
 
@@ -96,6 +97,19 @@ gethrestime(inode_timespec_t *ts)
 #endif
 }
 
+/*
+ * 4.20 kernels no longer have current_kernel_time(), only
+ * current_kernel_time64().
+ */
+#if !defined(HAVE_KERNEL_CURRENT_TIME) && defined(HAVE_INODE_TIMESPEC64_TIMES)
+static inline struct timespec current_kernel_time(void)
+{
+       struct timespec64 ts;
+       gethrestime(&ts);
+       return timespec64_to_timespec(ts);
+}
+#endif
+
 static inline time_t
 gethrestime_sec(void)
 {