Linux 4.20: current_kernel_time is gone 91/13391/3
authorMark Vitale <mvitale@sinenomine.net>
Tue, 13 Nov 2018 16:20:09 +0000 (11:20 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 22 Nov 2018 23:30:10 +0000 (18:30 -0500)
With Linux commit 976516404ff3fab2a8caa8bd6f5efc1437fed0b8 'y2038:
remove unused time interfaces' (4.20-rc1), current_kernel_time() has
been removed.

Many y2038-compliant time APIs were introduced with Linux commit
fb7fcc96a86cfaef0f6dcc0665516aa68611e736 'timekeeping: Standardize on
ktime_get_*() naming' (4.18).  According to
Documentation/core-api/timekeeping.rst, a suitable replacement for:

  struct timespec current_kernel_time(void)

would be:

  void ktime_get_coarse_real_ts64(struct timespec64 *ts))

Add an autoconf test and equivalent logic to deal.

Change-Id: I4ff622ad40cc6d398267276d13493d819b877350
Reviewed-on: https://gerrit.openafs.org/13391
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/afs/LINUX/osi_machdep.h
src/cf/linux-kernel-func.m4

index ce8cabf..a1a2f57 100644 (file)
 #if defined(HAVE_LINUX_CRED_H)
 #include "h/cred.h"
 #endif
-#if defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
+
+#if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
+static inline time_t osi_Time(void) {
+    struct timespec64 xtime;
+    ktime_get_coarse_real_ts64(&xtime);
+    return xtime.tv_sec;
+}
+#elif defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
 static inline time_t osi_Time(void) {
     struct timespec xtime;
     xtime = current_kernel_time();
index 0b17e17..62fd528 100644 (file)
@@ -72,6 +72,10 @@ AC_CHECK_LINUX_FUNC([iter_file_splice_write],
 AC_CHECK_LINUX_FUNC([kernel_setsockopt],
                     [#include <linux/net.h>],
                     [kernel_setsockopt(NULL, 0, 0, NULL, 0);])
+AC_CHECK_LINUX_FUNC([ktime_get_coarse_real_ts64],
+                    [#include <linux/time.h>],
+                    [struct timespec64 *s;
+                    ktime_get_coarse_real_ts64(s);])
 AC_CHECK_LINUX_FUNC([locks_lock_file_wait],
                     [#include <linux/fs.h>],
                     [locks_lock_file_wait(NULL, NULL);])