Skip to content

Commit 31a4673

Browse files
ckanebehlendorf
authored andcommitted
Linux 6.5 compat: register_sysctl_table removed
Additionally, the .child element of ctl_table has been removed in 6.5. This change adds a new test for the pre-6.5 register_sysctl_table() function, and uses the old code in that case. If it isn't found, then the parentage entries in the tables are removed, and the register_sysctl call is provided the paths of "kernel/spl", "kernel/spl/kmem", and "kernel/spl/kstat" directly, to populate each subdirectory over three calls, as is the new API. Reviewed-by: Brian Atkinson <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #15138
1 parent 3a68f3c commit 31a4673

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
dnl #
2+
dnl # Linux 6.5 removes register_sysctl_table
3+
dnl #
4+
AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE], [
5+
ZFS_LINUX_TEST_SRC([has_register_sysctl_table], [
6+
#include <linux/sysctl.h>
7+
8+
static struct ctl_table dummy_table[] = {
9+
{}
10+
};
11+
12+
],[
13+
struct ctl_table_header *h
14+
__attribute((unused)) = register_sysctl_table(dummy_table);
15+
])
16+
])
17+
18+
AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE], [
19+
AC_MSG_CHECKING([whether register_sysctl_table exists])
20+
ZFS_LINUX_TEST_RESULT([has_register_sysctl_table], [
21+
AC_MSG_RESULT([yes])
22+
AC_DEFINE(HAVE_REGISTER_SYSCTL_TABLE, 1,
23+
[register_sysctl_table exists])
24+
],[
25+
AC_MSG_RESULT([no])
26+
])
27+
])

config/kernel.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
160160
ZFS_AC_KERNEL_SRC_FILEMAP
161161
ZFS_AC_KERNEL_SRC_WRITEPAGE_T
162162
ZFS_AC_KERNEL_SRC_RECLAIMED
163+
ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE
163164
case "$host_cpu" in
164165
powerpc*)
165166
ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
@@ -299,6 +300,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
299300
ZFS_AC_KERNEL_FILEMAP
300301
ZFS_AC_KERNEL_WRITEPAGE_T
301302
ZFS_AC_KERNEL_RECLAIMED
303+
ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE
302304
case "$host_cpu" in
303305
powerpc*)
304306
ZFS_AC_KERNEL_CPU_HAS_FEATURE

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ static struct ctl_table spl_table[] = {
624624
.mode = 0644,
625625
.proc_handler = &proc_dohostid,
626626
},
627+
#ifdef HAVE_REGISTER_SYSCTL_TABLE
627628
{
628629
.procname = "kmem",
629630
.mode = 0555,
@@ -634,9 +635,11 @@ static struct ctl_table spl_table[] = {
634635
.mode = 0555,
635636
.child = spl_kstat_table,
636637
},
638+
#endif
637639
{},
638640
};
639641

642+
#ifdef HAVE_REGISTER_SYSCTL_TABLE
640643
static struct ctl_table spl_dir[] = {
641644
{
642645
.procname = "spl",
@@ -648,21 +651,38 @@ static struct ctl_table spl_dir[] = {
648651

649652
static struct ctl_table spl_root[] = {
650653
{
651-
.procname = "kernel",
652-
.mode = 0555,
653-
.child = spl_dir,
654+
.procname = "kernel",
655+
.mode = 0555,
656+
.child = spl_dir,
654657
},
655658
{}
656659
};
660+
#endif
657661

658662
int
659663
spl_proc_init(void)
660664
{
661665
int rc = 0;
662666

667+
#ifdef HAVE_REGISTER_SYSCTL_TABLE
663668
spl_header = register_sysctl_table(spl_root);
664669
if (spl_header == NULL)
665670
return (-EUNATCH);
671+
#else
672+
spl_header = register_sysctl("kernel/spl", spl_table);
673+
if (spl_header == NULL)
674+
return (-EUNATCH);
675+
676+
if (register_sysctl("kernel/spl/kmem", spl_kmem_table) == NULL) {
677+
rc = -EUNATCH;
678+
goto out;
679+
}
680+
681+
if (register_sysctl("kernel/spl/kstat", spl_kstat_table) == NULL) {
682+
rc = -EUNATCH;
683+
goto out;
684+
}
685+
#endif
666686

667687
proc_spl = proc_mkdir("spl", NULL);
668688
if (proc_spl == NULL) {

0 commit comments

Comments
 (0)