diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/vdev.c | 20 | ||||
-rw-r--r-- | module/zfs/zvol.c | 23 |
2 files changed, 30 insertions, 13 deletions
diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index e0d82e673..e374f6d78 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -42,6 +42,7 @@ #include <sys/arc.h> #include <sys/zil.h> #include <sys/dsl_scan.h> +#include <sys/zvol.h> /* * Virtual device management. @@ -1074,27 +1075,20 @@ vdev_open_child(void *arg) vd->vdev_open_thread = NULL; } -boolean_t +static boolean_t vdev_uses_zvols(vdev_t *vd) { -/* - * Stacking zpools on top of zvols is unsupported until we implement a method - * for determining if an arbitrary block device is a zvol without using the - * path. Solaris would check the 'zvol' path component but this does not - * exist in the Linux port, so we really should do something like stat the - * file and check the major number. This is complicated by the fact that - * we need to do this portably in user or kernel space. - */ -#if 0 int c; - if (vd->vdev_path && strncmp(vd->vdev_path, ZVOL_DIR, - strlen(ZVOL_DIR)) == 0) +#ifdef _KERNEL + if (zvol_is_zvol(vd->vdev_path)) return (B_TRUE); +#endif + for (c = 0; c < vd->vdev_children; c++) if (vdev_uses_zvols(vd->vdev_child[c])) return (B_TRUE); -#endif + return (B_FALSE); } diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 5d4802560..7a448f194 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -141,6 +141,29 @@ zvol_find_by_name(const char *name) return NULL; } + +/* + * Given a path, return TRUE if path is a ZVOL. + */ +boolean_t +zvol_is_zvol(const char *device) +{ + struct block_device *bdev; + unsigned int major; + + bdev = lookup_bdev(device); + if (IS_ERR(bdev)) + return (B_FALSE); + + major = MAJOR(bdev->bd_dev); + bdput(bdev); + + if (major == zvol_major) + return (B_TRUE); + + return (B_FALSE); +} + /* * ZFS_IOC_CREATE callback handles dmu zvol and zap object creation. */ |