]> git.proxmox.com Git - mirror_spl.git/commitdiff
Linux 2.6.39 compat, invalidate_inodes()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 18 Apr 2011 20:47:43 +0000 (13:47 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 19 Apr 2011 16:08:08 +0000 (09:08 -0700)
To resolve a potiential filesystem corruption issue a second
argument was added to invalidate_inodes().  This argument controls
whether dirty inodes are dropped or treated as busy when invalidating
a super block.  When only the legacy API is available the second
argument will be dropped for compatibility.

config/spl-build.m4
configure
include/linux/mm_compat.h
module/spl/spl-kmem.c
spl_config.h.in

index 94c7f3e7460382433bf4cb673cb3d87ba372a9f6..84fbb8b926cf896c82044b88cf27f188e3553edb 100644 (file)
@@ -76,6 +76,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_3ARGS_FILE_FSYNC
        SPL_AC_EXPORTED_RWSEM_IS_LOCKED
        SPL_AC_KERNEL_INVALIDATE_INODES
+       SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
        SPL_AC_SHRINK_DCACHE_MEMORY
        SPL_AC_SHRINK_ICACHE_MEMORY
 ])
@@ -1720,6 +1721,36 @@ AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
                [])
 ])
 
+dnl #
+dnl # 2.6.39 API compat,
+dnl # The function invalidate_inodes() now take 2 arguments.  The second
+dnl # 'kill_dirty' argument describes how invalidate_inodes() should
+dnl # handle dirty inodes.  Only when set will dirty inodes be discarded,
+dnl # otherwise they will be handled as busy.
+dnl #
+dnl # Unfortunately, we don't have access to the invalidate_inodes()
+dnl # prototype so it's not easy to check how many arguments it takes.
+dnl # However, this change was done for the benefit of invalidate_device()
+dnl # which also added an argument.  The invalidate_device() symbol does
+dnl # exist in the development headers so if it takes two arguments we
+dnl # can fairly safely infer that invalidate_inodes() takes two arguments
+dnl # as well.  See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
+       [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/fs.h>
+       ],[
+               return __invalidate_device(NULL, 0);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
+                         [invalidate_inodes() wants 2 args])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
 dnl #
 dnl # 2.6.xx API compat,
 dnl # There currently exists no exposed API to partially shrink the dcache.
index 317ab8ea72dc802d42ea90a5a29dda96f6c03835..f8dbd64657f0e25e3846237aef5020921afa7227 100755 (executable)
--- a/configure
+++ b/configure
@@ -15462,6 +15462,70 @@ _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; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/fs.h>
+
+int
+main (void)
+{
+
+               return __invalidate_device(NULL, 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_2ARGS_INVALIDATE_INODES 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
+
+
+
 
        { $as_echo "$as_me:$LINENO: checking whether symbol shrink_dcache_memory is exported" >&5
 $as_echo_n "checking whether symbol shrink_dcache_memory is exported... " >&6; }
@@ -19366,6 +19430,70 @@ _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; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+               #include <linux/fs.h>
+
+int
+main (void)
+{
+
+               return __invalidate_device(NULL, 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_2ARGS_INVALIDATE_INODES 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
+
+
+
 
        { $as_echo "$as_me:$LINENO: checking whether symbol shrink_dcache_memory is exported" >&5
 $as_echo_n "checking whether symbol shrink_dcache_memory is exported... " >&6; }
index 522db827f805e0fbd9353a621c149c887945625f..07231c9a41fa3541c31060aff20cccdd797c4e98 100644 (file)
  * The function invalidate_inodes() is no longer exported by the kernel.
  * The prototype however is still available which means it is safe
  * to acquire the symbol's address using spl_kallsyms_lookup_name().
+ *
+ * 2.6.39 API compat,
+ * As for 2.6.39 invalidate_inodes() was updated to take a second
+ * argument which controls how dirty inodes should be handled.
  */
-#ifndef HAVE_INVALIDATE_INODES
+#ifdef HAVE_INVALIDATE_INODES
+# ifdef HAVE_2ARGS_INVALIDATE_INODES
+#  define spl_invalidate_inodes(sb, kd)        invalidate_inodes(sb, kd)
+# else
+#  define spl_invalidate_inodes(sb, kd)        invalidate_inodes(sb)
+# endif /* HAVE_2ARGS_INVALIDATE_INODES */
+#else
+# ifdef HAVE_2ARGS_INVALIDATE_INODES
+typedef int (*invalidate_inodes_t)(struct super_block *sb, bool kd);
+extern invalidate_inodes_t invalidate_inodes_fn;
+#  define spl_invalidate_inodes(sb, kd)        invalidate_inodes_fn(sb, kd)
+# else
 typedef int (*invalidate_inodes_t)(struct super_block *sb);
 extern invalidate_inodes_t invalidate_inodes_fn;
-#define invalidate_inodes(sb)  invalidate_inodes_fn(sb)
+#  define spl_invalidate_inodes(sb, kd)        invalidate_inodes_fn(sb)
+# endif /* HAVE_2ARGS_INVALIDATE_INODES */
 #endif /* HAVE_INVALIDATE_INODES */
 
 /*
index d96456cbc767f8e4f2480228425f0a5fd84c9864..e7fc5f2c9108c043694172fc8b6ec3c1dbec2f32 100644 (file)
@@ -2105,7 +2105,7 @@ spl_kmem_init_kallsyms_lookup(void)
 
 #ifndef HAVE_INVALIDATE_INODES
        invalidate_inodes_fn = (invalidate_inodes_t)
-       spl_kallsyms_lookup_name("invalidate_inodes");
+               spl_kallsyms_lookup_name("invalidate_inodes");
        if (!invalidate_inodes_fn) {
                printk(KERN_ERR "Error: Unknown symbol invalidate_inodes\n");
                return -EFAULT;
index 284b9b1e964d8404c86d22b1cff025863f4d8cd4..afa1535facda66fe89f38c6b70aab8c74261795f 100644 (file)
@@ -9,6 +9,9 @@
 /* Define to 1 to enable detailed kmem tracking */
 #undef DEBUG_KMEM_TRACKING
 
+/* invalidate_inodes() wants 2 args */
+#undef HAVE_2ARGS_INVALIDATE_INODES
+
 /* register_sysctl_table() wants 2 args */
 #undef HAVE_2ARGS_REGISTER_SYSCTL