From a46237106cb48e7f4a1bf458d227981f291d59f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 19 Jan 2022 21:33:50 +0100 Subject: [PATCH] Linux 5.17 compat: dequeue_signal() takes a 4th argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux 5.17's dequeue_signal() takes an additional enum pid_type * output argument Upstream commit 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue") Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #12989 --- config/kernel-kthread.m4 | 45 ++++++++++++++++++++++++++++++-- module/os/linux/spl/spl-thread.c | 5 ++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/config/kernel-kthread.m4 b/config/kernel-kthread.m4 index 6459f831e7..f5b824d794 100644 --- a/config/kernel-kthread.m4 +++ b/config/kernel-kthread.m4 @@ -1,4 +1,4 @@ -AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [ +AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT], [ dnl # dnl # 5.17 API, dnl # cead18552660702a4a46f58e65188fe5f36e9dfe ("exit: Rename complete_and_exit to kthread_complete_and_exit") @@ -15,7 +15,24 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [ ]) ]) -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [ +AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ + dnl # + dnl # 5.17 API: enum pid_type * as new 4th dequeue_signal() argument, + dnl # 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue") + dnl # + dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info); + dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type); + dnl # + AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments]) + ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1, [dequeue_signal() takes 4 arguments]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [ ZFS_LINUX_TEST_SRC([kthread_complete_and_exit], [ #include ], [ @@ -25,3 +42,27 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [ kthread_complete_and_exit(completion, code); ]) ]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG], [ + ZFS_LINUX_TEST_SRC([kthread_dequeue_signal], [ + #include + ], [ + struct task_struct *task = NULL; + sigset_t *mask = NULL; + kernel_siginfo_t *info = NULL; + enum pid_type *type = NULL; + int error __attribute__ ((unused)); + + error = dequeue_signal(task, mask, info, type); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [ + ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT + ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [ + ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT + ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG +]) diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index 0ba4c18c16..16d2ca1b13 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -188,7 +188,12 @@ issig(int why) spin_lock_irq(&task->sighand->siglock); int ret; +#ifdef HAVE_DEQUEUE_SIGNAL_4ARG + enum pid_type __type; + if ((ret = dequeue_signal(task, &set, &__info, &__type)) != 0) { +#else if ((ret = dequeue_signal(task, &set, &__info)) != 0) { +#endif #ifdef HAVE_SIGNAL_STOP spin_unlock_irq(&task->sighand->siglock); kernel_signal_stop();