]> git.proxmox.com Git - pve-kernel-jessie.git/blame - zfs-fix-zpool-import-bug-with-nested-pools.patch
drop sd-fix-rw_max.patch applied upstream
[pve-kernel-jessie.git] / zfs-fix-zpool-import-bug-with-nested-pools.patch
CommitLineData
ab3cbe8e
FG
1From e02aaf17f15ad274fa1f24c9c826f1477911ea3f Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Hajo=20M=C3=B6ller?= <dasjoe@users.noreply.github.com>
3Date: Wed, 26 Oct 2016 19:30:43 +0200
4Subject: [PATCH] Fix lookup_bdev() on Ubuntu
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Ubuntu added support for checking inode permissions to lookup_bdev() in kernel
10commit 193fb6a2c94fab8eb8ce70a5da4d21c7d4023bee (merged in 4.4.0-6.21).
11Upstream bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1636517
12
13This patch adds a test for Ubuntu's variant of lookup_bdev() to configure and
14calls the function in the correct way.
15
16Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
17Signed-off-by: Hajo Möller <dasjoe@gmail.com>
18Closes #5336
19---
20 config/kernel-lookup-bdev.m4 | 22 +++++++++++++++++-----
21 include/linux/blkdev_compat.h | 17 +++++++++++++----
22 module/zfs/zvol.c | 2 +-
23 3 files changed, 31 insertions(+), 10 deletions(-)
24
25diff --git a/config/kernel-lookup-bdev.m4 b/config/kernel-lookup-bdev.m4
26index 245f95f..abbf55d 100644
27--- a/config/kernel-lookup-bdev.m4
28+++ b/config/kernel-lookup-bdev.m4
29@@ -1,17 +1,29 @@
30 dnl #
31-dnl # 2.6.27 API change
32-dnl # lookup_bdev() was exported.
33+dnl # 2.6.27, lookup_bdev() was exported.
34+dnl # 4.4.0-6.21 - x.y on Ubuntu, lookup_bdev() takes 2 arguments.
35 dnl #
36 AC_DEFUN([ZFS_AC_KERNEL_LOOKUP_BDEV],
37- [AC_MSG_CHECKING([whether lookup_bdev() is available])
38+ [AC_MSG_CHECKING([whether lookup_bdev() wants 1 arg])
39 ZFS_LINUX_TRY_COMPILE_SYMBOL([
40 #include <linux/fs.h>
41 ], [
42 lookup_bdev(NULL);
43 ], [lookup_bdev], [fs/block_dev.c], [
44 AC_MSG_RESULT(yes)
45- AC_DEFINE(HAVE_LOOKUP_BDEV, 1, [lookup_bdev() is available])
46+ AC_DEFINE(HAVE_1ARG_LOOKUP_BDEV, 1, [lookup_bdev() wants 1 arg])
47 ], [
48 AC_MSG_RESULT(no)
49+ AC_MSG_CHECKING([whether lookup_bdev() wants 2 args])
50+ ZFS_LINUX_TRY_COMPILE_SYMBOL([
51+ #include <linux/fs.h>
52+ ], [
53+ lookup_bdev(NULL, FMODE_READ);
54+ ], [lookup_bdev], [fs/block_dev.c], [
55+ AC_MSG_RESULT(yes)
56+ AC_DEFINE(HAVE_2ARGS_LOOKUP_BDEV, 1,
57+ [lookup_bdev() wants 2 args])
58+ ], [
59+ AC_MSG_RESULT(no)
60+ ])
61 ])
62-])
63+])
64\ No newline at end of file
65diff --git a/include/linux/blkdev_compat.h b/include/linux/blkdev_compat.h
66index bff93ff..1f90b98 100644
67--- a/include/linux/blkdev_compat.h
68+++ b/include/linux/blkdev_compat.h
69@@ -263,12 +263,21 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
70
71 /*
72 * 2.6.27 API change
73- * The function was exported for use, prior to this it existed by the
74+ * The function was exported for use, prior to this it existed but the
75 * symbol was not exported.
76+ *
77+ * 4.4.0-6.21 API change for Ubuntu
78+ * lookup_bdev() gained a second argument, FMODE_*, to check inode permissions.
79 */
80-#ifndef HAVE_LOOKUP_BDEV
81-#define lookup_bdev(path) ERR_PTR(-ENOTSUP)
82-#endif
83+#ifdef HAVE_1ARG_LOOKUP_BDEV
84+#define vdev_lookup_bdev(path) lookup_bdev(path)
85+#else
86+#ifdef HAVE_2ARGS_LOOKUP_BDEV
87+#define vdev_lookup_bdev(path) lookup_bdev(path, 0)
88+#else
89+#define vdev_lookup_bdev(path) ERR_PTR(-ENOTSUP)
90+#endif /* HAVE_2ARGS_LOOKUP_BDEV */
91+#endif /* HAVE_1ARG_LOOKUP_BDEV */
92
93 /*
94 * 2.6.30 API change
95diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
96index bf6d59f..72a6bc5 100644
97--- a/module/zfs/zvol.c
98+++ b/module/zfs/zvol.c
99@@ -174,7 +174,7 @@ zvol_is_zvol(const char *device)
100 struct block_device *bdev;
101 unsigned int major;
102
103- bdev = lookup_bdev(device);
104+ bdev = vdev_lookup_bdev(device);
105 if (IS_ERR(bdev))
106 return (B_FALSE);
107