]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: (noup) Update spl with 4.15 compat fix (LP:#1737761)
authorColin Ian King <colin.king@canonical.com>
Tue, 12 Dec 2017 14:59:44 +0000 (14:59 +0000)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 29 Jan 2018 13:45:06 +0000 (07:45 -0600)
Add a 4.15 spl compat fix to detect and use timer_setup instead of the deprecated
init_timer.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
spl/config/spl-build.m4
spl/configure
spl/module/spl/spl-taskq.c
spl/spl_config.h.in

index accf6759bfbe54b31135702f8f16c2a3b8702bd1..3b1a49522a091ed863df34e8d8a490adf614760a 100644 (file)
@@ -56,6 +56,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_WAIT_QUEUE_HEAD_ENTRY
        SPL_AC_KERNEL_WRITE
        SPL_AC_KERNEL_READ
+       SPL_AC_TIMER_SETUP
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
@@ -1755,3 +1756,27 @@ AC_DEFUN([SPL_AC_KERNEL_READ], [
        ])
        EXTRA_KCFLAGS="$tmp_flags"
 ])
+
+dnl #
+dnl # 4.16 new API
+dnl # new timer_setup()
+dnl #
+AC_DEFUN([SPL_AC_TIMER_SETUP], [
+       AC_MSG_CHECKING([whether timer_setup() exists])
+       tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-Werror"
+       SPL_LINUX_TRY_COMPILE([
+                #include <linux/timer.h>
+        ],[
+               struct timer_list timer;
+
+               timer_setup(&timer, NULL, 0);
+        ],[
+                AC_MSG_RESULT(yes)
+                AC_DEFINE(HAVE_KERNEL_TIMER_SETUP, 1,
+                    [use timer_setup() for timer initialization])
+        ],[
+                AC_MSG_RESULT(no)
+        ])
+        EXTRA_KCFLAGS="$tmp_flags"
+])
index c7a7c43caa53a4ee2675134ced28a3ca2c08744a..7c9941711a9e32e38c028ce24a50d73bc9959922 100755 (executable)
 
        EXTRA_KCFLAGS="$tmp_flags"
 
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether timer_setup() exists" >&5
+$as_echo_n "checking whether timer_setup() exists... " >&6; }
+       tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-Werror"
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+                #include <linux/timer.h>
+
+int
+main (void)
+{
+
+               struct timer_list timer;
+
+               timer_setup(&timer, NULL, 0);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+       echo "obj-m := conftest.o" >build/Makefile
+       modpost_flag=''
+       test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_KERNEL_TIMER_SETUP 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+       rm -Rf build
+
+
+        EXTRA_KCFLAGS="$tmp_flags"
+
  ;;
                user)      ;;
                all)
        EXTRA_KCFLAGS="$tmp_flags"
 
 
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether timer_setup() exists" >&5
+$as_echo_n "checking whether timer_setup() exists... " >&6; }
+       tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-Werror"
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+
+
+                #include <linux/timer.h>
+
+int
+main (void)
+{
+
+               struct timer_list timer;
+
+               timer_setup(&timer, NULL, 0);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+
+
+       rm -Rf build && mkdir -p build && touch build/conftest.mod.c
+       echo "obj-m := conftest.o" >build/Makefile
+       modpost_flag=''
+       test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
+       if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_KERNEL_TIMER_SETUP 1" >>confdefs.h
+
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
+fi
+       rm -Rf build
+
+
+        EXTRA_KCFLAGS="$tmp_flags"
+
+
                           ;;
                srpm)                        ;;
                *)
index 86915e62f2252ccf4bb6dea4988bb9de68fa4c3c..4b7b3f7ce22d721d85d3b548a38ebf270f2e05c3 100644 (file)
@@ -209,9 +209,17 @@ task_done(taskq_t *tq, taskq_ent_t *t)
  * add it to the priority list in order for immediate processing.
  */
 static void
+#ifdef HAVE_KERNEL_TIMER_SETUP
+task_expire(struct timer_list *tl)
+#else
 task_expire(unsigned long data)
+#endif
 {
+#ifdef HAVE_KERNEL_TIMER_SETUP
+       taskq_ent_t *w, *t = (taskq_ent_t *)from_timer(t, tl, tqent_timer);
+#else
        taskq_ent_t *w, *t = (taskq_ent_t *)data;
+#endif
        taskq_t *tq = t->tqent_taskq;
        struct list_head *l;
        unsigned long flags;
@@ -590,8 +598,12 @@ taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags)
        t->tqent_func = func;
        t->tqent_arg = arg;
        t->tqent_taskq = tq;
+#ifdef HAVE_KERNEL_TIMER_SETUP
+       timer_setup(&t->tqent_timer, NULL, 0);
+#else
        t->tqent_timer.data = 0;
        t->tqent_timer.function = NULL;
+#endif
        t->tqent_timer.expires = 0;
        t->tqent_birth = jiffies;
 
@@ -640,8 +652,12 @@ taskq_dispatch_delay(taskq_t *tq, task_func_t func, void *arg,
        t->tqent_func = func;
        t->tqent_arg = arg;
        t->tqent_taskq = tq;
+#ifdef HAVE_KERNEL_TIMER_SETUP
+       timer_setup(&t->tqent_timer, task_expire, 0);
+#else
        t->tqent_timer.data = (unsigned long)t;
        t->tqent_timer.function = task_expire;
+#endif
        t->tqent_timer.expires = (unsigned long)expire_time;
        add_timer(&t->tqent_timer);
 
@@ -732,7 +748,11 @@ taskq_init_ent(taskq_ent_t *t)
 {
        spin_lock_init(&t->tqent_lock);
        init_waitqueue_head(&t->tqent_waitq);
+#ifdef HAVE_KERNEL_TIMER_SETUP
+       timer_setup(&t->tqent_timer, NULL, 0);
+#else
        init_timer(&t->tqent_timer);
+#endif
        INIT_LIST_HEAD(&t->tqent_list);
        t->tqent_id = 0;
        t->tqent_func = NULL;
index 6f2249d4113070b968ad330d45b9afc7053b8b8c..7d2a4d9d16289959ea8f9a113944ba9f19024e60 100644 (file)
@@ -81,6 +81,9 @@
 /* kernel_read() take loff_t pointer */
 #undef HAVE_KERNEL_READ_PPOS
 
+/* use timer_setup() for timer initialization */
+#undef HAVE_KERNEL_TIMER_SETUP
+
 /* kernel_write() take loff_t pointer */
 #undef HAVE_KERNEL_WRITE_PPOS