Skip to content

Commit 21cba06

Browse files
authored
config: fix dequeue_signal check for kernels <4.20
Before 4.20, kernel_siginfo_t was just called siginfo_t. This was causing the kthread_dequeue_signal_3arg_task check, which uses kernel_siginfo_t, to fail on older kernels. In d6b8c17, we started checking for the "new" three-arg dequeue_signal() by testing for the "old" version. Because that test is explicitly using kernel_siginfo_t, it would fail, leading to the build trying to use the new three-arg version, which would then not compile. This commit fixes that by avoiding checking for the old 3-arg dequeue_signal entirely. Instead, we check for the new one, as well as the 4-arg form, and we use the old form as a fallback. This way, we never have to test for it explicitly, and once we're building HAVE_SIGINFO will make sure we get the right kernel_siginfo_t for it, so everything works out nice. Original-patch-by: Finix <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #16666
1 parent b2f6de7 commit 21cba06

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

config/kernel-kthread.m4

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT], [
1717

1818
AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL], [
1919
dnl #
20-
dnl # 5.17 API: enum pid_type * as new 4th dequeue_signal() argument,
21-
dnl # 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue")
20+
dnl # prehistory:
21+
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask,
22+
dnl # siginfo_t *info)
2223
dnl #
23-
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info);
24-
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
24+
dnl # 4.20: kernel_siginfo_t introduced, replaces siginfo_t
25+
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask,
26+
dnl kernel_siginfo_t *info)
2527
dnl #
26-
dnl # 6.12 API: first arg struct_task* removed
27-
dnl # int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
28+
dnl # 5.17: enum pid_type introduced as 4th arg
29+
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask,
30+
dnl # kernel_siginfo_t *info, enum pid_type *type)
31+
dnl #
32+
dnl # 6.12: first arg struct_task* removed
33+
dnl # int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info,
34+
dnl # enum pid_type *type)
2835
dnl #
2936
AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments])
3037
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_4arg], [
@@ -33,11 +40,11 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL], [
3340
[dequeue_signal() takes 4 arguments])
3441
], [
3542
AC_MSG_RESULT(no)
36-
AC_MSG_CHECKING([whether dequeue_signal() a task argument])
37-
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_task], [
43+
AC_MSG_CHECKING([whether 3-arg dequeue_signal() takes a type argument])
44+
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_type], [
3845
AC_MSG_RESULT(yes)
39-
AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TASK, 1,
40-
[dequeue_signal() takes a task argument])
46+
AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TYPE, 1,
47+
[3-arg dequeue_signal() takes a type argument])
4148
], [
4249
AC_MSG_RESULT(no)
4350
])
@@ -56,27 +63,27 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [
5663
])
5764

5865
AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL], [
59-
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_task], [
66+
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [
6067
#include <linux/sched/signal.h>
6168
], [
6269
struct task_struct *task = NULL;
6370
sigset_t *mask = NULL;
6471
kernel_siginfo_t *info = NULL;
72+
enum pid_type *type = NULL;
6573
int error __attribute__ ((unused));
6674
67-
error = dequeue_signal(task, mask, info);
75+
error = dequeue_signal(task, mask, info, type);
6876
])
6977
70-
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [
78+
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_type], [
7179
#include <linux/sched/signal.h>
7280
], [
73-
struct task_struct *task = NULL;
7481
sigset_t *mask = NULL;
7582
kernel_siginfo_t *info = NULL;
7683
enum pid_type *type = NULL;
7784
int error __attribute__ ((unused));
7885
79-
error = dequeue_signal(task, mask, info, type);
86+
error = dequeue_signal(mask, info, type);
8087
])
8188
])
8289

module/os/linux/spl/spl-thread.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ issig(void)
171171
#if defined(HAVE_DEQUEUE_SIGNAL_4ARG)
172172
enum pid_type __type;
173173
if (dequeue_signal(current, &set, &__info, &__type) != 0) {
174-
#elif defined(HAVE_DEQUEUE_SIGNAL_3ARG_TASK)
175-
if (dequeue_signal(current, &set, &__info) != 0) {
176-
#else
174+
#elif defined(HAVE_DEQUEUE_SIGNAL_3ARG_TYPE)
177175
enum pid_type __type;
178176
if (dequeue_signal(&set, &__info, &__type) != 0) {
177+
#else
178+
if (dequeue_signal(current, &set, &__info) != 0) {
179179
#endif
180180
spin_unlock_irq(&current->sighand->siglock);
181181
kernel_signal_stop();

0 commit comments

Comments
 (0)