From 6c2856726fbae681649930d9620d9087080e58fc Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Mon, 17 Dec 2012 10:33:57 +0900 Subject: Fix using zvol as slog device During the original ZoL port the vdev_uses_zvols() function was disabled until it could be properly implemented. This prevented a zpool from use a zvol for its slog device. This patch implements that missing functionality by adding a zvol_is_zvol() function to zvol.c. Given the full path to a device it will lookup the device and verify its major number against the registered zvol major number for the system. If they match we know the device is a zvol. Signed-off-by: Brian Behlendorf Closes #1131 --- module/zfs/zvol.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'module/zfs/zvol.c') 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. */ -- cgit v1.2.3