From a9856574cffd8fac7702424cc6134c5e0b5325b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 19 Jan 2022 21:10:49 +0100 Subject: [PATCH] Linux 5.17 compat: detect complete_and_exit() rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux 5.17 sees a rename from complete_and_exit() to kthread complete_and_exit() Upstream commit cead18552660702a4a46f58e65188fe5f36e9dfe ("exit: Rename complete_and_exit to kthread_complete_and_exit") Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #12989 --- config/kernel-kthread.m4 | 27 +++++++++++++++++++++++++++ config/kernel.m4 | 2 ++ module/os/linux/spl/spl-thread.c | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 config/kernel-kthread.m4 diff --git a/config/kernel-kthread.m4 b/config/kernel-kthread.m4 new file mode 100644 index 000000000..6459f831e --- /dev/null +++ b/config/kernel-kthread.m4 @@ -0,0 +1,27 @@ +AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [ + dnl # + dnl # 5.17 API, + dnl # cead18552660702a4a46f58e65188fe5f36e9dfe ("exit: Rename complete_and_exit to kthread_complete_and_exit") + dnl # + dnl # Also moves the definition from include/linux/kernel.h to include/linux/kthread.h + dnl # + AC_MSG_CHECKING([whether kthread_complete_and_exit() is available]) + ZFS_LINUX_TEST_RESULT([kthread_complete_and_exit], [ + AC_MSG_RESULT(yes) + AC_DEFINE(SPL_KTHREAD_COMPLETE_AND_EXIT, kthread_complete_and_exit, [kthread_complete_and_exit() available]) + ], [ + AC_MSG_RESULT(no) + AC_DEFINE(SPL_KTHREAD_COMPLETE_AND_EXIT, complete_and_exit, [using complete_and_exit() instead]) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [ + ZFS_LINUX_TEST_SRC([kthread_complete_and_exit], [ + #include + ], [ + struct completion *completion = NULL; + long code = 0; + + kthread_complete_and_exit(completion, code); + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index b3ed966b7..1adec975c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -136,6 +136,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_SRC_ADD_DISK + ZFS_AC_KERNEL_SRC_KTHREAD AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -245,6 +246,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_ADD_DISK + ZFS_AC_KERNEL_KTHREAD ]) dnl # diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index 834c52711..0ba4c18c1 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -66,7 +66,7 @@ void __thread_exit(void) { tsd_exit(); - complete_and_exit(NULL, 0); + SPL_KTHREAD_COMPLETE_AND_EXIT(NULL, 0); /* Unreachable */ } EXPORT_SYMBOL(__thread_exit);