From 586d4e9f7bdd7038365c06fc983f45b3113fb1d0 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 12 Dec 2017 14:59:44 +0000 Subject: [PATCH] UBUNTU: SAUCE: (noup) Update spl with 4.15 compat fix (LP:#1737761) 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 Signed-off-by: Seth Forshee --- spl/config/spl-build.m4 | 25 ++++++++ spl/configure | 128 +++++++++++++++++++++++++++++++++++++ spl/module/spl/spl-taskq.c | 20 ++++++ spl/spl_config.h.in | 3 + 4 files changed, 176 insertions(+) diff --git a/spl/config/spl-build.m4 b/spl/config/spl-build.m4 index accf6759bfbe..3b1a49522a09 100644 --- a/spl/config/spl-build.m4 +++ b/spl/config/spl-build.m4 @@ -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 + ],[ + 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" +]) diff --git a/spl/configure b/spl/configure index c7a7c43caa53..7c9941711a9e 100755 --- a/spl/configure +++ b/spl/configure @@ -15654,6 +15654,70 @@ fi 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 + +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) @@ -18919,6 +18983,70 @@ fi 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 + +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) ;; *) diff --git a/spl/module/spl/spl-taskq.c b/spl/module/spl/spl-taskq.c index 86915e62f225..4b7b3f7ce22d 100644 --- a/spl/module/spl/spl-taskq.c +++ b/spl/module/spl/spl-taskq.c @@ -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; diff --git a/spl/spl_config.h.in b/spl/spl_config.h.in index 6f2249d41130..7d2a4d9d1628 100644 --- a/spl/spl_config.h.in +++ b/spl/spl_config.h.in @@ -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 -- 2.39.5