From 5f6c14b1eda9c7b47d11a3b90e78dea6a7f429e0 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Dec 2011 14:22:45 -0800 Subject: [PATCH] Proxmox VE kernel compat, invalidate_inodes() The Proxmox VE kernel contains a patch which renames the function invalidate_inodes() to invalidate_inodes_check(). In the process it adds a 'check' argument and a '#define invalidate_inodes(x)' compatibility wrapper for legacy callers. Therefore, if either of these functions are exported invalidate_inodes() can be safely used. Signed-off-by: Brian Behlendorf Closes #58 --- config/spl-build.m4 | 13 +++++++ configure | 78 +++++++++++++++++++++++++++++++++++++++ include/linux/mm_compat.h | 4 +- module/spl/spl-kmem.c | 8 ++-- spl_config.h.in | 3 ++ 5 files changed, 100 insertions(+), 6 deletions(-) diff --git a/config/spl-build.m4 b/config/spl-build.m4 index 7b66535..90ff680 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -1816,6 +1816,13 @@ dnl # The function invalidate_inodes() is no longer exported by the kernel. dnl # The prototype however is still available which means it is safe dnl # to acquire the symbol's address using spl_kallsyms_lookup_name(). dnl # +dnl # The Proxmox VE kernel contains a patch which renames the function +dnl # invalidate_inodes() to invalidate_inodes_check(). In the process +dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)' +dnl # compatibility wrapper for legacy callers. Therefore, if either +dnl # of these functions are exported invalidate_inodes() can be +dnl # safely used. +dnl # AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [ SPL_CHECK_SYMBOL_EXPORT( [invalidate_inodes], @@ -1823,6 +1830,12 @@ AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [ [AC_DEFINE(HAVE_INVALIDATE_INODES, 1, [invalidate_inodes() is available])], []) + SPL_CHECK_SYMBOL_EXPORT( + [invalidate_inodes_check], + [], + [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1, + [invalidate_inodes_check() is available])], + []) ]) dnl # diff --git a/configure b/configure index fc27ad1..9d95d76 100755 --- a/configure +++ b/configure @@ -15638,6 +15638,45 @@ _ACEOF fi + { $as_echo "$as_me:$LINENO: checking whether symbol invalidate_inodes_check is exported" >&5 +$as_echo_n "checking whether symbol invalidate_inodes_check is exported... " >&6; } + grep -q -E '[[:space:]]invalidate_inodes_check[[:space:]]' \ + $LINUX_OBJ/Module*.symvers 2>/dev/null + rc=$? + if test $rc -ne 0; then + export=0 + for file in ; do + grep -q -E "EXPORT_SYMBOL.*(invalidate_inodes_check)" \ + "$LINUX_OBJ/$file" 2>/dev/null + rc=$? + if test $rc -eq 0; then + export=1 + break; + fi + done + if test $export -eq 0; then + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INVALIDATE_INODES_CHECK 1 +_ACEOF + + fi + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INVALIDATE_INODES_CHECK 1 +_ACEOF + + fi + { $as_echo "$as_me:$LINENO: checking whether invalidate_inodes() wants 2 args" >&5 $as_echo_n "checking whether invalidate_inodes() wants 2 args... " >&6; } @@ -19908,6 +19947,45 @@ _ACEOF fi + { $as_echo "$as_me:$LINENO: checking whether symbol invalidate_inodes_check is exported" >&5 +$as_echo_n "checking whether symbol invalidate_inodes_check is exported... " >&6; } + grep -q -E '[[:space:]]invalidate_inodes_check[[:space:]]' \ + $LINUX_OBJ/Module*.symvers 2>/dev/null + rc=$? + if test $rc -ne 0; then + export=0 + for file in ; do + grep -q -E "EXPORT_SYMBOL.*(invalidate_inodes_check)" \ + "$LINUX_OBJ/$file" 2>/dev/null + rc=$? + if test $rc -eq 0; then + export=1 + break; + fi + done + if test $export -eq 0; then + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INVALIDATE_INODES_CHECK 1 +_ACEOF + + fi + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_INVALIDATE_INODES_CHECK 1 +_ACEOF + + fi + { $as_echo "$as_me:$LINENO: checking whether invalidate_inodes() wants 2 args" >&5 $as_echo_n "checking whether invalidate_inodes() wants 2 args... " >&6; } diff --git a/include/linux/mm_compat.h b/include/linux/mm_compat.h index b375f9b..14fc3d7 100644 --- a/include/linux/mm_compat.h +++ b/include/linux/mm_compat.h @@ -54,7 +54,7 @@ * As for 2.6.39 invalidate_inodes() was updated to take a second * argument which controls how dirty inodes should be handled. */ -#ifdef HAVE_INVALIDATE_INODES +#if defined(HAVE_INVALIDATE_INODES) || defined(HAVE_INVALIDATE_INODES_CHECK) # ifdef HAVE_2ARGS_INVALIDATE_INODES # define spl_invalidate_inodes(sb, kd) invalidate_inodes(sb, kd) # else @@ -70,7 +70,7 @@ typedef int (*invalidate_inodes_t)(struct super_block *sb); extern invalidate_inodes_t invalidate_inodes_fn; # define spl_invalidate_inodes(sb, kd) invalidate_inodes_fn(sb) # endif /* HAVE_2ARGS_INVALIDATE_INODES */ -#endif /* HAVE_INVALIDATE_INODES */ +#endif /* HAVE_INVALIDATE_INODES || HAVE_INVALIDATE_INODES_CHECK */ #if !defined(HAVE_SHRINK_CONTROL_STRUCT) struct shrink_control { diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index 1d2fa90..5a6011a 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -180,10 +180,10 @@ spl_global_page_state(spl_zone_stat_item_t item) #endif /* NEED_GET_ZONE_COUNTS */ EXPORT_SYMBOL(spl_global_page_state); -#ifndef HAVE_INVALIDATE_INODES +#if !defined(HAVE_INVALIDATE_INODES) && !defined(HAVE_INVALIDATE_INODES_CHECK) invalidate_inodes_t invalidate_inodes_fn = SYMBOL_POISON; EXPORT_SYMBOL(invalidate_inodes_fn); -#endif /* HAVE_INVALIDATE_INODES */ +#endif /* !HAVE_INVALIDATE_INODES && !HAVE_INVALIDATE_INODES_CHECK */ #ifndef HAVE_SHRINK_DCACHE_MEMORY shrink_dcache_memory_t shrink_dcache_memory_fn = SYMBOL_POISON; @@ -2113,14 +2113,14 @@ spl_kmem_init_kallsyms_lookup(void) */ spl_kmem_init_globals(); -#ifndef HAVE_INVALIDATE_INODES +#if !defined(HAVE_INVALIDATE_INODES) && !defined(HAVE_INVALIDATE_INODES_CHECK) invalidate_inodes_fn = (invalidate_inodes_t) spl_kallsyms_lookup_name("invalidate_inodes"); if (!invalidate_inodes_fn) { printk(KERN_ERR "Error: Unknown symbol invalidate_inodes\n"); return -EFAULT; } -#endif /* HAVE_INVALIDATE_INODES */ +#endif /* !HAVE_INVALIDATE_INODES && !HAVE_INVALIDATE_INODES_CHECK */ #ifndef HAVE_SHRINK_DCACHE_MEMORY /* When shrink_dcache_memory_fn == NULL support is disabled */ diff --git a/spl_config.h.in b/spl_config.h.in index 08b4342..94e28e7 100644 --- a/spl_config.h.in +++ b/spl_config.h.in @@ -111,6 +111,9 @@ /* invalidate_inodes() is available */ #undef HAVE_INVALIDATE_INODES +/* invalidate_inodes_check() is available */ +#undef HAVE_INVALIDATE_INODES_CHECK + /* kallsyms_lookup_name() is available */ #undef HAVE_KALLSYMS_LOOKUP_NAME -- 2.39.5