From f548d1a00eaf705607b0c1eac254c95e3905f5b2 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 22 Feb 2017 17:31:06 -0500 Subject: [PATCH] LU-9118 o2iblnd: handle MOFED libcfs time api collision Both libcfs and the MOFED 4 stack define ktime_get_real_ns() for platforms that lack it. The solution is to reverse the logic of testing for ktime_get_real_ns() done by lustre. This way we avoid the HAVE_KTIME_GET_REAL_NS collision. Also to ensure older platforms with an older OFED stack still will build only turn off NEED_KTIME_GET_REAL_NS set by libcfs in o2iblnd.h when the OFED stack has defined LINUX_3_17_COMPAT_H. The compat-3.17.h OFED header is where ktime_get_real_ns() gets defined when its lacking on the native platform. Test-Parameters: trivial Change-Id: I44966f22cfbb6138fa7bc3fa47148a6f0a94ebd4 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/25564 Tested-by: Jenkins Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 10 +++++----- libcfs/include/libcfs/linux/linux-time.h | 4 ++-- lnet/klnds/o2iblnd/o2iblnd.h | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 3740297..979b815 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -365,19 +365,19 @@ ktime_get_real_seconds, [ ]) # LIBCFS_KTIME_GET_REAL_SECONDS # -# Kernel version 3.17 created ktime_get_ns wrapper +# Kernel version 3.17 created ktime_get_real_ns wrapper # AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[ LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist], -ktime_get_ns, [ +ktime_get_real_ns, [ #include ],[ u64 nanoseconds; nanoseconds = ktime_get_real_ns(); -],[ - AC_DEFINE(HAVE_KTIME_GET_REAL_NS, 1, - ['ktime_get_real_ns' is available]) +],[],[ + AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1, + ['ktime_get_real_ns' is not available]) ]) ]) # LIBCFS_KTIME_GET_REAL_NS diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index bf403ff..6c1004d 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -145,12 +145,12 @@ time64_t ktime_get_real_seconds(void); time64_t ktime_get_seconds(void); #endif /* HAVE_KTIME_GET_SECONDS */ -#ifndef HAVE_KTIME_GET_REAL_NS +#ifdef NEED_KTIME_GET_REAL_NS static inline u64 ktime_get_real_ns(void) { return ktime_to_ns(ktime_get_real()); } -#endif /* HAVE_KTIME_GET_NS */ +#endif /* NEED_KTIME_GET_REAL_NS */ static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2) { diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index fe17e08..298a355 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -36,6 +36,11 @@ #ifdef HAVE_COMPAT_RDMA #include + +#ifdef LINUX_3_17_COMPAT_H +#undef NEED_KTIME_GET_REAL_NS +#endif + #endif #include -- 1.8.3.1