From c96d401d9e044e412ea162d530273476de34211a Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Thu, 13 Jul 2023 10:54:22 -0600 Subject: [PATCH 03/10] Linux 6.5: Use register_sysctl() The linux 6.5 commit: "sysctl: Remove register_sysctl_table" (b8cbc0855a) removed the Linux function register_sysctl_table(). The replacement function is register_sysctl(), which offers a simpler interface. Add an autoconf test for the Linux function register_sysctl and add a call to register_sysctl when available. Notes: The Linux function register_sysctl was added in Linux 3.3 with the commit: 'sysctl: Add register_sysctl for normal sysctl users' (fea478d410) with a note that it is a simpler interface. The function register_sysctl_table was marked as deprecated with the Linux 6.3 commit: 'proc_sysctl: enhance documentation' (1dc8689e4c) Reviewed-on: https://gerrit.openafs.org/15500 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit fb31d299e6caa015f6288ba9186da6277d3d6a8d) Change-Id: I60f68f1dd95c32bada7179e98250fd44d7c2ddf3 Reviewed-on: https://gerrit.openafs.org/15522 Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Reviewed-by: Stephan Wiesand (cherry picked from commit 63801cfd1fc06ec3259fcfd67229f3a3c70447ed) --- src/afs/LINUX/osi_sysctl.c | 8 +++++--- src/cf/linux-kernel-assorted.m4 | 4 +++- src/cf/linux-kernel-func.m4 | 8 ++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/afs/LINUX/osi_sysctl.c b/src/afs/LINUX/osi_sysctl.c index 894c49412..a0a039892 100644 --- a/src/afs/LINUX/osi_sysctl.c +++ b/src/afs/LINUX/osi_sysctl.c @@ -79,7 +79,7 @@ static struct ctl_table afs_sysctl_table[] = { .procname = 0 } }; - +# if !defined(HAVE_LINUX_REGISTER_SYSCTL) static struct ctl_table fs_sysctl_table[] = { { AFS_SYSCTL_NAME(1) @@ -91,11 +91,13 @@ static struct ctl_table fs_sysctl_table[] = { .procname = 0 } }; - +# endif int osi_sysctl_init(void) { -# if defined(REGISTER_SYSCTL_TABLE_NOFLAG) +# if defined(HAVE_LINUX_REGISTER_SYSCTL) + afs_sysctl = register_sysctl("afs", afs_sysctl_table); +# elif defined(REGISTER_SYSCTL_TABLE_NOFLAG) afs_sysctl = register_sysctl_table(fs_sysctl_table); # else afs_sysctl = register_sysctl_table(fs_sysctl_table, 0); diff --git a/src/cf/linux-kernel-assorted.m4 b/src/cf/linux-kernel-assorted.m4 index 03d5f6583..b3a11bc3a 100644 --- a/src/cf/linux-kernel-assorted.m4 +++ b/src/cf/linux-kernel-assorted.m4 @@ -39,7 +39,9 @@ LINUX_LINUX_KEYRING_SUPPORT LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK LINUX_KEY_ALLOC_NEEDS_CRED LINUX_INIT_WORK_HAS_DATA -LINUX_REGISTER_SYSCTL_TABLE_NOFLAG +dnl Don't bother checking register_sysctl_table if using register_sysctl +AS_IF([test "x$ac_cv_linux_func_register_sysctl" != "xyes"], + [LINUX_REGISTER_SYSCTL_TABLE_NOFLAG]) LINUX_HAVE_DCACHE_LOCK LINUX_D_COUNT_IS_INT LINUX_IOP_GETATTR_TAKES_PATH_STRUCT diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 index ee22158db..811954915 100644 --- a/src/cf/linux-kernel-func.m4 +++ b/src/cf/linux-kernel-func.m4 @@ -217,6 +217,14 @@ AC_CHECK_LINUX_FUNC([block_dirty_folio], #include ], [block_dirty_folio(NULL, NULL);]) +dnl Linux 6.5 removed the Linux function register_sysctl_table(), which +dnl was deprecated in Linux 6.3 in favor of register_sysctl() which was +dnl introduced in Linux 3.3 +AC_CHECK_LINUX_FUNC([register_sysctl], + [#include + #include ], + [(void)register_sysctl(NULL, NULL);]) + dnl Consequences - things which get set as a result of the dnl above tests AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"], -- 2.43.0