[PATCH] zfs: fix zpool import bug with nested pools

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Oct 25 14:07:07 UTC 2016


this was broken since Ubuntu-4.4.0-6.21, which contained

193fb6a2c94fab8eb8ce70a5da4d21c7d4023bee UBUNTU: SAUCE: block_dev: Support checking inode permissions in lookup_bdev()

without this fix, ZFS does not detect vdevs on zvols
correctly, which causes a soft hang when importing zpools
consisting of such vdevs.

note the comment in zfs/module/zfs/vdev.c , 1141-1143:

in order to handle pools on top of zvols, do the opens in a
single thread so that the same thread holds the
spa_namespace_lock

BugLink: http://bugs.launchpad.net/bugs/1636517

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
fix tested with 4.4.0-45.66

note that instead of hardcoding the patched variant of lookup_bdev, it might
make sense to adapt the zfs automake files to autodetect and handle both one
parameter and two parameter variants?

that way, all three variations of building the zfs module would work and the
change could be proposed to upstream zfs:

dkms source with either an Ubuntu or upstream kernel Ubuntu kernel with zfs
module source in module/zfs/

 zfs/config/kernel-lookup-bdev.m4 | 2 +-
 zfs/module/zfs/zvol.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/zfs/config/kernel-lookup-bdev.m4 b/zfs/config/kernel-lookup-bdev.m4
index 245f95f..123e238 100644
--- a/zfs/config/kernel-lookup-bdev.m4
+++ b/zfs/config/kernel-lookup-bdev.m4
@@ -7,7 +7,7 @@ AC_DEFUN([ZFS_AC_KERNEL_LOOKUP_BDEV],
 	ZFS_LINUX_TRY_COMPILE_SYMBOL([
 		#include <linux/fs.h>
 	], [
-		lookup_bdev(NULL);
+		lookup_bdev(NULL, 0);
 	], [lookup_bdev], [fs/block_dev.c], [
 		AC_MSG_RESULT(yes)
 		AC_DEFINE(HAVE_LOOKUP_BDEV, 1, [lookup_bdev() is available])
diff --git a/zfs/module/zfs/zvol.c b/zfs/module/zfs/zvol.c
index 04f68b5..2fd8bb0 100644
--- a/zfs/module/zfs/zvol.c
+++ b/zfs/module/zfs/zvol.c
@@ -174,7 +174,7 @@ zvol_is_zvol(const char *device)
 	struct block_device *bdev;
 	unsigned int major;
 
-	bdev = lookup_bdev(device);
+	bdev = lookup_bdev(device, 0);
 	if (IS_ERR(bdev))
 		return (B_FALSE);
 
-- 
2.1.4






More information about the kernel-team mailing list