Whamcloud - gitweb
LU-11200 libcfs: handle DECLARE_TIMER reduced to two arguments 39/32939/5
authorJames Simmons <uja.ornl@yahoo.com>
Mon, 6 Aug 2018 17:56:55 +0000 (13:56 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Aug 2018 02:23:45 +0000 (02:23 +0000)
For the linux kernel their exist two ways to initialize a
struct timer_list. One method is with setup_timer() and the other is
with the DEFINE_TIMER macro. For earlier kernels both methods employed
callbacked with a argument of the type unsigned long. In kernels 4.15+
both methods of initialization use struct timer_list pointer for its
callback argument. During the 4.14 development phase we have
setup_timer() using struct timer_list as an argument for its callback
but DEFINE_TIMER was still using unsigned long. Additionally when
DEFINE_TIMER did move to using struct timer_list it reduced the number
of arguments to the macro. This patch handles the 4.14 kernel state of
development for the timer API.

Test-Parameters: trivial

Change-Id: I1c509838153328ed4bbdfa50468a396e13037d50
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32939
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-time.h
lustre/ldlm/ldlm_lockd.c

index 4774cac..0803c70 100644 (file)
@@ -858,6 +858,25 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_NEW_KERNEL_WRITE
 
 #
 ]) # LIBCFS_NEW_KERNEL_WRITE
 
 #
+# LIBCFS_DEFINE_TIMER
+#
+# Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
+# remove expires and data arguments from DEFINE_TIMER. Also the callback
+# when from using unsigned long argument to using struct timer_list pointer.
+#
+AC_DEFUN([LIBCFS_DEFINE_TIMER], [
+LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
+define_timer, [
+       #include <linux/timer.h>
+],[
+       static DEFINE_TIMER(my_timer, NULL);
+],[
+       AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
+               [DEFINE_TIMER uses only 2 arguements])
+])
+]) # LIBCFS_DEFINE_TIMER
+
+#
 # LIBCFS_TIMER_SETUP
 #
 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
 # LIBCFS_TIMER_SETUP
 #
 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
@@ -958,6 +977,7 @@ LIBCFS_SCHED_HEADERS
 # 4.13
 LIBCFS_WAIT_QUEUE_ENTRY
 # 4.14
 # 4.13
 LIBCFS_WAIT_QUEUE_ENTRY
 # 4.14
+LIBCFS_DEFINE_TIMER
 LIBCFS_NEW_KERNEL_WRITE
 # 4.15
 LIBCFS_TIMER_SETUP
 LIBCFS_NEW_KERNEL_WRITE
 # 4.15
 LIBCFS_TIMER_SETUP
index b5be95e..5af8134 100644 (file)
@@ -197,22 +197,34 @@ static inline unsigned long cfs_time_seconds(time64_t seconds)
        return nsecs_to_jiffies(seconds * NSEC_PER_SEC);
 }
 
        return nsecs_to_jiffies(seconds * NSEC_PER_SEC);
 }
 
+#ifdef HAVE_NEW_DEFINE_TIMER
+# ifndef TIMER_DATA_TYPE
+# define TIMER_DATA_TYPE struct timer_list *
+# endif
+
+#define CFS_DEFINE_TIMER(_name, _function, _expires, _data) \
+       DEFINE_TIMER((_name), (_function))
+#else
+# ifndef TIMER_DATA_TYPE
+# define TIMER_DATA_TYPE unsigned long
+# endif
+
+#define CFS_DEFINE_TIMER(_name, _function, _expires, _data) \
+       DEFINE_TIMER((_name), (_function), (_expires), (_data))
+#endif
+
 #ifdef HAVE_TIMER_SETUP
 #define cfs_timer_cb_arg_t struct timer_list *
 #define cfs_from_timer(var, callback_timer, timer_fieldname) \
        from_timer(var, callback_timer, timer_fieldname)
 #define cfs_timer_setup(timer, callback, data, flags) \
        timer_setup((timer), (callback), (flags))
 #ifdef HAVE_TIMER_SETUP
 #define cfs_timer_cb_arg_t struct timer_list *
 #define cfs_from_timer(var, callback_timer, timer_fieldname) \
        from_timer(var, callback_timer, timer_fieldname)
 #define cfs_timer_setup(timer, callback, data, flags) \
        timer_setup((timer), (callback), (flags))
-#define CFS_DEFINE_TIMER(_name, _function, _expires, _data) \
-       DEFINE_TIMER((_name), (_function))
 #define cfs_timer_cb_arg(var, timer_fieldname) (&(var)->timer_fieldname)
 #else
 #define cfs_timer_cb_arg_t unsigned long
 #define cfs_from_timer(var, data, timer_fieldname) (typeof(var))(data)
 #define cfs_timer_setup(timer, callback, data, flags) \
        setup_timer((timer), (callback), (data))
 #define cfs_timer_cb_arg(var, timer_fieldname) (&(var)->timer_fieldname)
 #else
 #define cfs_timer_cb_arg_t unsigned long
 #define cfs_from_timer(var, data, timer_fieldname) (typeof(var))(data)
 #define cfs_timer_setup(timer, callback, data, flags) \
        setup_timer((timer), (callback), (data))
-#define CFS_DEFINE_TIMER(_name, _function, _expires, _data) \
-       DEFINE_TIMER((_name), (_function), (_expires), (_data))
 #define cfs_timer_cb_arg(var, timer_fieldname) (cfs_timer_cb_arg_t)(var)
 #endif
 
 #define cfs_timer_cb_arg(var, timer_fieldname) (cfs_timer_cb_arg_t)(var)
 #endif
 
index 3273fdc..c0b4edc 100644 (file)
@@ -131,7 +131,7 @@ static DEFINE_SPINLOCK(waiting_locks_spinlock); /* BH lock (timer) */
  * All access to it should be under waiting_locks_spinlock.
  */
 static LIST_HEAD(waiting_locks_list);
  * All access to it should be under waiting_locks_spinlock.
  */
 static LIST_HEAD(waiting_locks_list);
-static void waiting_locks_callback(cfs_timer_cb_arg_t unused);
+static void waiting_locks_callback(TIMER_DATA_TYPE unused);
 static CFS_DEFINE_TIMER(waiting_locks_timer, waiting_locks_callback, 0, 0);
 
 enum elt_state {
 static CFS_DEFINE_TIMER(waiting_locks_timer, waiting_locks_callback, 0, 0);
 
 enum elt_state {
@@ -303,7 +303,7 @@ static int ldlm_lock_busy(struct ldlm_lock *lock)
 }
 
 /* This is called from within a timer interrupt and cannot schedule */
 }
 
 /* This is called from within a timer interrupt and cannot schedule */
-static void waiting_locks_callback(cfs_timer_cb_arg_t unused)
+static void waiting_locks_callback(TIMER_DATA_TYPE unused)
 {
        struct ldlm_lock        *lock;
        int                     need_dump = 0;
 {
        struct ldlm_lock        *lock;
        int                     need_dump = 0;