From 79a3bf130b78cae41be339917788dde0b45c7d84 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 30 Jun 2010 10:36:20 -0700 Subject: [PATCH] Linux-2.6.33 compat, .ctl_name removed from struct ctl_table As of linux-2.6.33 the ctl_name member of the ctl_table struct has been entirely removed. The upstream code has been updated to depend entirely on the the procname member. To handle this all references to ctl_name are wrapped in a CTL_NAME macro which simply expands to nothing for newer kernels. Older kernels are supported by having it expand to .ctl_name = X just as before. --- config/spl-build.m4 | 20 ++++++ configure | 132 ++++++++++++++++++++++++++++++++++++ include/linux/proc_compat.h | 6 ++ module/spl/spl-proc.c | 78 ++++++++++----------- spl_config.h.in | 3 + 5 files changed, 201 insertions(+), 38 deletions(-) diff --git a/config/spl-build.m4 b/config/spl-build.m4 index c6f47b68f..135783cdc 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -36,6 +36,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_PATH_IN_NAMEIDATA SPL_AC_TASK_CURR SPL_AC_CTL_UNNUMBERED + SPL_AC_CTL_NAME SPL_AC_FLS64 SPL_AC_DEVICE_CREATE SPL_AC_5ARGS_DEVICE_CREATE @@ -641,6 +642,25 @@ AC_DEFUN([SPL_AC_CTL_UNNUMBERED], ]) ]) +dnl # +dnl # 2.6.33 API change, +dnl # Removed .ctl_name from struct ctl_table. +dnl # +AC_DEFUN([SPL_AC_CTL_NAME], [ + AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + struct ctl_table ctl; + ctl.ctl_name = 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + dnl # dnl # 2.6.16 API change. dnl # Check if 'fls64()' is available diff --git a/configure b/configure index 47611aeec..fe3de76dc 100755 --- a/configure +++ b/configure @@ -12360,6 +12360,72 @@ $as_echo "no" >&6; } +fi + + rm -Rf build + + + + + { $as_echo "$as_me:$LINENO: checking whether struct ctl_table has ctl_name" >&5 +$as_echo_n "checking whether struct ctl_table has ctl_name... " >&6; } + + +cat >conftest.c <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + + #include + +int +main (void) +{ + + struct ctl_table ctl; + ctl.ctl_name = 0; + + ; + return 0; +} + +_ACEOF + + + rm -Rf build && mkdir -p build + echo "obj-m := conftest.o" >build/Makefile + if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CTL_NAME 1 +_ACEOF + + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + + fi rm -Rf build @@ -15757,6 +15823,72 @@ $as_echo "no" >&6; } +fi + + rm -Rf build + + + + + { $as_echo "$as_me:$LINENO: checking whether struct ctl_table has ctl_name" >&5 +$as_echo_n "checking whether struct ctl_table has ctl_name... " >&6; } + + +cat >conftest.c <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + + #include + +int +main (void) +{ + + struct ctl_table ctl; + ctl.ctl_name = 0; + + ; + return 0; +} + +_ACEOF + + + rm -Rf build && mkdir -p build + echo "obj-m := conftest.o" >build/Makefile + if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CTL_NAME 1 +_ACEOF + + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + + fi rm -Rf build diff --git a/include/linux/proc_compat.h b/include/linux/proc_compat.h index c30f9db8e..97d3c6c5a 100644 --- a/include/linux/proc_compat.h +++ b/include/linux/proc_compat.h @@ -36,6 +36,12 @@ #define spl_unregister_sysctl_table(t) unregister_sysctl_table(t) #endif /* CONFIG_SYSCTL */ +#ifdef HAVE_CTL_NAME +#define CTL_NAME(cname) .ctl_name = (cname), +#else +#define CTL_NAME(cname) +#endif + extern struct proc_dir_entry *proc_spl_kstat; struct proc_dir_entry *proc_dir_entry_find(struct proc_dir_entry *root, const char *str); diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c index 277a92a7a..5a71f795c 100644 --- a/module/spl/spl-proc.c +++ b/module/spl/spl-proc.c @@ -52,6 +52,7 @@ static struct proc_dir_entry *proc_spl_kmem_slab = NULL; #endif /* DEBUG_KMEM */ struct proc_dir_entry *proc_spl_kstat = NULL; +#ifdef HAVE_CTL_NAME #ifdef HAVE_CTL_UNNUMBERED #define CTL_SPL CTL_UNNUMBERED @@ -153,6 +154,7 @@ enum { #endif }; #endif /* HAVE_CTL_UNNUMBERED */ +#endif /* HAVE_CTL_NAME */ static int proc_copyin_string(char *kbuffer, int kbuffer_size, @@ -661,7 +663,7 @@ static struct file_operations proc_slab_operations = { static struct ctl_table spl_debug_table[] = { { - .ctl_name = CTL_DEBUG_SUBSYS, + CTL_NAME (CTL_DEBUG_SUBSYS) .procname = "subsystem", .data = &spl_debug_subsys, .maxlen = sizeof(unsigned long), @@ -669,7 +671,7 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dobitmasks }, { - .ctl_name = CTL_DEBUG_MASK, + CTL_NAME (CTL_DEBUG_MASK) .procname = "mask", .data = &spl_debug_mask, .maxlen = sizeof(unsigned long), @@ -677,7 +679,7 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dobitmasks }, { - .ctl_name = CTL_DEBUG_PRINTK, + CTL_NAME (CTL_DEBUG_PRINTK) .procname = "printk", .data = &spl_debug_printk, .maxlen = sizeof(unsigned long), @@ -685,13 +687,13 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dobitmasks }, { - .ctl_name = CTL_DEBUG_MB, + CTL_NAME (CTL_DEBUG_MB) .procname = "mb", .mode = 0644, .proc_handler = &proc_debug_mb, }, { - .ctl_name = CTL_DEBUG_BINARY, + CTL_NAME (CTL_DEBUG_BINARY) .procname = "binary", .data = &spl_debug_binary, .maxlen = sizeof(int), @@ -699,7 +701,7 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_DEBUG_CATASTROPHE, + CTL_NAME (CTL_DEBUG_CATASTROPHE) .procname = "catastrophe", .data = &spl_debug_catastrophe, .maxlen = sizeof(int), @@ -707,7 +709,7 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_DEBUG_PANIC_ON_BUG, + CTL_NAME (CTL_DEBUG_PANIC_ON_BUG) .procname = "panic_on_bug", .data = &spl_debug_panic_on_bug, .maxlen = sizeof(int), @@ -715,7 +717,7 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dointvec }, { - .ctl_name = CTL_DEBUG_PATH, + CTL_NAME (CTL_DEBUG_PATH) .procname = "path", .data = spl_debug_file_path, .maxlen = sizeof(spl_debug_file_path), @@ -723,18 +725,18 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dostring, }, { - .ctl_name = CTL_DEBUG_DUMP, + CTL_NAME (CTL_DEBUG_DUMP) .procname = "dump", .mode = 0200, .proc_handler = &proc_dump_kernel, }, - { .ctl_name = CTL_DEBUG_FORCE_BUG, + { CTL_NAME (CTL_DEBUG_FORCE_BUG) .procname = "force_bug", .mode = 0200, .proc_handler = &proc_force_bug, }, { - .ctl_name = CTL_CONSOLE_RATELIMIT, + CTL_NAME (CTL_CONSOLE_RATELIMIT) .procname = "console_ratelimit", .data = &spl_console_ratelimit, .maxlen = sizeof(int), @@ -742,28 +744,28 @@ static struct ctl_table spl_debug_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_CONSOLE_MAX_DELAY_CS, + CTL_NAME (CTL_CONSOLE_MAX_DELAY_CS) .procname = "console_max_delay_centisecs", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_console_max_delay_cs, }, { - .ctl_name = CTL_CONSOLE_MIN_DELAY_CS, + CTL_NAME (CTL_CONSOLE_MIN_DELAY_CS) .procname = "console_min_delay_centisecs", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_console_min_delay_cs, }, { - .ctl_name = CTL_CONSOLE_BACKOFF, + CTL_NAME (CTL_CONSOLE_BACKOFF) .procname = "console_backoff", .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_console_backoff, }, { - .ctl_name = CTL_DEBUG_STACK_SIZE, + CTL_NAME (CTL_DEBUG_STACK_SIZE) .procname = "stack_max", .data = &spl_debug_stack, .maxlen = sizeof(int), @@ -775,7 +777,7 @@ static struct ctl_table spl_debug_table[] = { static struct ctl_table spl_vm_table[] = { { - .ctl_name = CTL_VM_MINFREE, + CTL_NAME (CTL_VM_MINFREE) .procname = "minfree", .data = &minfree, .maxlen = sizeof(int), @@ -783,7 +785,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_DESFREE, + CTL_NAME (CTL_VM_DESFREE) .procname = "desfree", .data = &desfree, .maxlen = sizeof(int), @@ -791,7 +793,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_LOTSFREE, + CTL_NAME (CTL_VM_LOTSFREE) .procname = "lotsfree", .data = &lotsfree, .maxlen = sizeof(int), @@ -799,7 +801,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_NEEDFREE, + CTL_NAME (CTL_VM_NEEDFREE) .procname = "needfree", .data = &needfree, .maxlen = sizeof(int), @@ -807,7 +809,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_SWAPFS_MINFREE, + CTL_NAME (CTL_VM_SWAPFS_MINFREE) .procname = "swapfs_minfree", .data = &swapfs_minfree, .maxlen = sizeof(int), @@ -815,7 +817,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_SWAPFS_RESERVE, + CTL_NAME (CTL_VM_SWAPFS_RESERVE) .procname = "swapfs_reserve", .data = &swapfs_reserve, .maxlen = sizeof(int), @@ -823,13 +825,13 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dointvec, }, { - .ctl_name = CTL_VM_AVAILRMEM, + CTL_NAME (CTL_VM_AVAILRMEM) .procname = "availrmem", .mode = 0444, .proc_handler = &proc_doavailrmem, }, { - .ctl_name = CTL_VM_FREEMEM, + CTL_NAME (CTL_VM_FREEMEM) .procname = "freemem", .data = (void *)2, .maxlen = sizeof(int), @@ -837,7 +839,7 @@ static struct ctl_table spl_vm_table[] = { .proc_handler = &proc_dofreemem, }, { - .ctl_name = CTL_VM_PHYSMEM, + CTL_NAME (CTL_VM_PHYSMEM) .procname = "physmem", .data = &physmem, .maxlen = sizeof(int), @@ -850,7 +852,7 @@ static struct ctl_table spl_vm_table[] = { #ifdef DEBUG_KMEM static struct ctl_table spl_kmem_table[] = { { - .ctl_name = CTL_KMEM_KMEMUSED, + CTL_NAME (CTL_KMEM_KMEMUSED) .procname = "kmem_used", .data = &kmem_alloc_used, # ifdef HAVE_ATOMIC64_T @@ -862,7 +864,7 @@ static struct ctl_table spl_kmem_table[] = { .proc_handler = &proc_domemused, }, { - .ctl_name = CTL_KMEM_KMEMMAX, + CTL_NAME (CTL_KMEM_KMEMMAX) .procname = "kmem_max", .data = &kmem_alloc_max, .maxlen = sizeof(unsigned long), @@ -872,7 +874,7 @@ static struct ctl_table spl_kmem_table[] = { .proc_handler = &proc_doulongvec_minmax, }, { - .ctl_name = CTL_KMEM_VMEMUSED, + CTL_NAME (CTL_KMEM_VMEMUSED) .procname = "vmem_used", .data = &vmem_alloc_used, # ifdef HAVE_ATOMIC64_T @@ -884,7 +886,7 @@ static struct ctl_table spl_kmem_table[] = { .proc_handler = &proc_domemused, }, { - .ctl_name = CTL_KMEM_VMEMMAX, + CTL_NAME (CTL_KMEM_VMEMMAX) .procname = "vmem_max", .data = &vmem_alloc_max, .maxlen = sizeof(unsigned long), @@ -906,7 +908,7 @@ static struct ctl_table spl_table[] = { * sysctl(8) prefers to go via /proc for portability. */ { - .ctl_name = CTL_VERSION, + CTL_NAME (CTL_VERSION) .procname = "version", .data = spl_version, .maxlen = sizeof(spl_version), @@ -914,7 +916,7 @@ static struct ctl_table spl_table[] = { .proc_handler = &proc_dostring, }, { - .ctl_name = CTL_HOSTID, + CTL_NAME (CTL_HOSTID) .procname = "hostid", .data = &spl_hostid, .maxlen = sizeof(unsigned long), @@ -922,7 +924,7 @@ static struct ctl_table spl_table[] = { .proc_handler = &proc_dohostid, }, { - .ctl_name = CTL_HW_SERIAL, + CTL_NAME (CTL_HW_SERIAL) .procname = "hw_serial", .data = hw_serial, .maxlen = sizeof(hw_serial), @@ -931,7 +933,7 @@ static struct ctl_table spl_table[] = { }, #ifndef HAVE_KALLSYMS_LOOKUP_NAME { - .ctl_name = CTL_KALLSYMS, + CTL_NAME (CTL_KALLSYMS) .procname = "kallsyms_lookup_name", .data = &spl_kallsyms_lookup_name_fn, .maxlen = sizeof(unsigned long), @@ -940,27 +942,27 @@ static struct ctl_table spl_table[] = { }, #endif { - .ctl_name = CTL_SPL_DEBUG, + CTL_NAME (CTL_SPL_DEBUG) .procname = "debug", .mode = 0555, .child = spl_debug_table, }, { - .ctl_name = CTL_SPL_VM, + CTL_NAME (CTL_SPL_VM) .procname = "vm", .mode = 0555, .child = spl_vm_table, }, #ifdef DEBUG_KMEM { - .ctl_name = CTL_SPL_KMEM, + CTL_NAME (CTL_SPL_KMEM) .procname = "kmem", .mode = 0555, .child = spl_kmem_table, }, #endif { - .ctl_name = CTL_SPL_KSTAT, + CTL_NAME (CTL_SPL_KSTAT) .procname = "kstat", .mode = 0555, .child = spl_kstat_table, @@ -970,7 +972,7 @@ static struct ctl_table spl_table[] = { static struct ctl_table spl_dir[] = { { - .ctl_name = CTL_SPL, + CTL_NAME (CTL_SPL) .procname = "spl", .mode = 0555, .child = spl_table, @@ -980,7 +982,7 @@ static struct ctl_table spl_dir[] = { static struct ctl_table spl_root[] = { { - .ctl_name = CTL_KERN, + CTL_NAME (CTL_KERN) .procname = "kernel", .mode = 0555, .child = spl_dir, diff --git a/spl_config.h.in b/spl_config.h.in index fdef876b3..a22ca7b8b 100644 --- a/spl_config.h.in +++ b/spl_config.h.in @@ -48,6 +48,9 @@ /* struct cred exists */ #undef HAVE_CRED_STRUCT +/* struct ctl_table has ctl_name */ +#undef HAVE_CTL_NAME + /* unnumbered sysctl support exists */ #undef HAVE_CTL_UNNUMBERED