Linux 2.6.26 compat, lookup_bdev()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 28 Jan 2013 22:15:39 +0000 (14:15 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 28 Jan 2013 23:35:00 +0000 (15:35 -0800)
It's doubtful many people were impacted by this but commit 6c28567
accidentally broke ZFS builds for 2.6.26 and earlier kernels.  This
commit depends on the lookup_bdev() function which exists in 2.6.26
but wasn't exported until 2.6.27.

The availability of the function isn't critical so a wrapper is
introduced which returns ERR_PTR(-ENOTSUP) when the function isn't
defined.  This will have the effect of causing zvol_is_zvol() to
always fail for 2.6.26 kernels.  This in turn means vdevs will
always get opened concurrently which is good for normal usage.
This will only become an issue if your using a zvol as a vdev in
another pool.  In which case you really should be using a newer
kernel anyway.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1205

config/kernel-lookup-bdev.m4 [new file with mode: 0644]
config/kernel.m4
include/linux/blkdev_compat.h

diff --git a/config/kernel-lookup-bdev.m4 b/config/kernel-lookup-bdev.m4
new file mode 100644 (file)
index 0000000..245f95f
--- /dev/null
@@ -0,0 +1,17 @@
+dnl #
+dnl # 2.6.27 API change
+dnl # lookup_bdev() was exported.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_LOOKUP_BDEV],
+       [AC_MSG_CHECKING([whether lookup_bdev() is available])
+       ZFS_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/fs.h>
+       ], [
+               lookup_bdev(NULL);
+       ], [lookup_bdev], [fs/block_dev.c], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_LOOKUP_BDEV, 1, [lookup_bdev() is available])
+       ], [
+               AC_MSG_RESULT(no)
+       ])
+])
index fd6ab1f..6d28074 100644 (file)
@@ -12,6 +12,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_3ARG_BLKDEV_GET
        ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
        ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE
+       ZFS_AC_KERNEL_LOOKUP_BDEV
        ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS
        ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE
        ZFS_AC_KERNEL_BDEV_PHYSICAL_BLOCK_SIZE
index 1ff8eea..9d3e6f0 100644 (file)
@@ -393,6 +393,15 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
 #endif /* HAVE_1ARG_INVALIDATE_BDEV */
 
 /*
+ * 2.6.27 API change
+ * The function was exported for use, prior to this it existed by the
+ * symbol was not exported.
+ */
+#ifndef HAVE_LOOKUP_BDEV
+# define lookup_bdev(path)             ERR_PTR(-ENOTSUP)
+#endif
+
+/*
  * 2.6.30 API change
  * To ensure good performance preferentially use the physical block size
  * for proper alignment.  The physical size is supposed to be the internal