diff -Nru zfs-linux-2.2.0~rc3/debian/changelog zfs-linux-2.2.0~rc3/debian/changelog --- zfs-linux-2.2.0~rc3/debian/changelog 2023-09-01 21:25:13.000000000 +0000 +++ zfs-linux-2.2.0~rc3/debian/changelog 2023-09-06 07:03:35.000000000 +0000 @@ -1,3 +1,10 @@ +zfs-linux (2.2.0~rc3-0ubuntu4) mantic; urgency=medium + + * Properly unregister sysctl entries when spl is unloaded (LP: #2034510): + - debian/patches/4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch + + -- Andrea Righi Wed, 06 Sep 2023 09:03:35 +0200 + zfs-linux (2.2.0~rc3-0ubuntu3) mantic; urgency=medium * Cherrypick upstream pull request 15234 to hopefully fix diff -Nru zfs-linux-2.2.0~rc3/debian/patches/4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch zfs-linux-2.2.0~rc3/debian/patches/4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch --- zfs-linux-2.2.0~rc3/debian/patches/4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-2.2.0~rc3/debian/patches/4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch 2023-09-06 07:03:35.000000000 +0000 @@ -0,0 +1,69 @@ +From: Andrea Righi +Subject: [PATCH] Linux 6.5 compat: spl: properly unregister sysctl entries +Origin: upstream, https://github.com/openzfs/zfs/pull/15239 + +When register_sysctl_table() is unavailable we fail to properly +unregister sysctl entries under "kernel/spl". + +This leads to errors like the following when spl is unloaded/reloaded, +making impossible to properly reload the spl module: + + [ 746.995704] sysctl duplicate entry: /kernel/spl/kmem/slab_kvmem_total + +Fix by cleaning up all the sub-entries inside "kernel/spl" when the +spl module is unloaded. + +Signed-off-by: Andrea Righi +--- + module/os/linux/spl/spl-proc.c | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +Index: zfs-linux-2.2.0~rc3/module/os/linux/spl/spl-proc.c +=================================================================== +--- zfs-linux-2.2.0~rc3.orig/module/os/linux/spl/spl-proc.c ++++ zfs-linux-2.2.0~rc3/module/os/linux/spl/spl-proc.c +@@ -47,6 +47,10 @@ static unsigned long table_min = 0; + static unsigned long table_max = ~0; + + static struct ctl_table_header *spl_header = NULL; ++#ifndef HAVE_REGISTER_SYSCTL_TABLE ++static struct ctl_table_header *spl_kmem = NULL; ++static struct ctl_table_header *spl_kstat = NULL; ++#endif + static struct proc_dir_entry *proc_spl = NULL; + static struct proc_dir_entry *proc_spl_kmem = NULL; + static struct proc_dir_entry *proc_spl_kmem_slab = NULL; +@@ -668,6 +672,16 @@ static void spl_proc_cleanup(void) + remove_proc_entry("taskq", proc_spl); + remove_proc_entry("spl", NULL); + ++#ifndef HAVE_REGISTER_SYSCTL_TABLE ++ if (spl_kstat) { ++ unregister_sysctl_table(spl_kstat); ++ spl_kstat = NULL; ++ } ++ if (spl_kmem) { ++ unregister_sysctl_table(spl_kmem); ++ spl_kmem = NULL; ++ } ++#endif + if (spl_header) { + unregister_sysctl_table(spl_header); + spl_header = NULL; +@@ -688,12 +702,13 @@ spl_proc_init(void) + if (spl_header == NULL) + return (-EUNATCH); + +- if (register_sysctl("kernel/spl/kmem", spl_kmem_table) == NULL) { ++ spl_kmem = register_sysctl("kernel/spl/kmem", spl_kmem_table); ++ if (spl_kmem == NULL) { + rc = -EUNATCH; + goto out; + } +- +- if (register_sysctl("kernel/spl/kstat", spl_kstat_table) == NULL) { ++ spl_kstat = register_sysctl("kernel/spl/kstat", spl_kstat_table); ++ if (spl_kstat == NULL) { + rc = -EUNATCH; + goto out; + } diff -Nru zfs-linux-2.2.0~rc3/debian/patches/series zfs-linux-2.2.0~rc3/debian/patches/series --- zfs-linux-2.2.0~rc3/debian/patches/series 2023-09-01 21:25:07.000000000 +0000 +++ zfs-linux-2.2.0~rc3/debian/patches/series 2023-09-06 07:03:35.000000000 +0000 @@ -37,3 +37,4 @@ fixup-abi.patch 4630-ubsan-Support-varlen-arrays-at-end-of-struct-as-1-or.patch ab09fbd4c2ca565c146060b7b2e1dd8c6fe0a818.patch +4635-Linux-6.5-compat-spl-properly-unregister-sysctl-entr.patch