summaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorFajar A. Nugraha <[email protected]>2011-02-22 17:58:44 +0700
committerBrian Behlendorf <[email protected]>2011-02-25 09:43:19 -0800
commit4c0d8e50b99b4f3b4a9b7bc67ac7fc4e406f5755 (patch)
tree4d1baadba665aa9f15ac34d729f41440c1edf24c /module/zfs
parent61da501f9d93f305d21d5d61fa3ecd476bdbac93 (diff)
Use udev to create /dev/zvol/[dataset_name] links
This commit allows zvols with names longer than 32 characters, which fixes issue on https://github.com/behlendorf/zfs/issues/#issue/102. Changes include: - use /dev/zd* device names for zvol, where * is the device minor (include/sys/fs/zfs.h, module/zfs/zvol.c). - add BLKZNAME ioctl to get dataset name from userland (include/sys/fs/zfs.h, module/zfs/zvol.c, cmd/zvol_id). - add udev rule to create /dev/zvol/[dataset_name] and the legacy /dev/[dataset_name] symlink. For partitions on zvol, it will create /dev/zvol/[dataset_name]-part* (etc/udev/rules.d/60-zvol.rules, cmd/zvol_id). Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/zvol.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index e4487f9a6..65a924057 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -58,7 +58,7 @@ static char *zvol_tag = "zvol_tag";
* The in-core state of each volume.
*/
typedef struct zvol_state {
- char zv_name[DISK_NAME_LEN]; /* name */
+ char zv_name[MAXNAMELEN]; /* name */
uint64_t zv_volsize; /* advertised space */
uint64_t zv_volblocksize;/* volume block size */
objset_t *zv_objset; /* objset handle */
@@ -132,7 +132,7 @@ zvol_find_by_name(const char *name)
ASSERT(MUTEX_HELD(&zvol_state_lock));
for (zv = list_head(&zvol_state_list); zv != NULL;
zv = list_next(&zvol_state_list, zv)) {
- if (!strncmp(zv->zv_name, name, DISK_NAME_LEN))
+ if (!strncmp(zv->zv_name, name, MAXNAMELEN))
return zv;
}
@@ -895,6 +895,9 @@ zvol_ioctl(struct block_device *bdev, fmode_t mode,
case BLKFLSBUF:
zil_commit(zv->zv_zilog, ZVOL_OBJ);
break;
+ case BLKZNAME:
+ error = copy_to_user((void *)arg, zv->zv_name, MAXNAMELEN);
+ break;
default:
error = -ENOTTY;
@@ -1058,7 +1061,7 @@ zvol_alloc(dev_t dev, const char *name)
zv->zv_queue->queuedata = zv;
zv->zv_dev = dev;
zv->zv_open_count = 0;
- strlcpy(zv->zv_name, name, DISK_NAME_LEN);
+ strlcpy(zv->zv_name, name, MAXNAMELEN);
mutex_init(&zv->zv_znode.z_range_lock, NULL, MUTEX_DEFAULT, NULL);
avl_create(&zv->zv_znode.z_range_avl, zfs_range_compare,
@@ -1073,7 +1076,8 @@ zvol_alloc(dev_t dev, const char *name)
zv->zv_disk->fops = &zvol_ops;
zv->zv_disk->private_data = zv;
zv->zv_disk->queue = zv->zv_queue;
- snprintf(zv->zv_disk->disk_name, DISK_NAME_LEN, "%s", name);
+ snprintf(zv->zv_disk->disk_name, DISK_NAME_LEN, "%s%d",
+ ZVOL_DEV_NAME, (dev & MINORMASK));
return zv;
@@ -1274,7 +1278,7 @@ zvol_remove_minors(const char *pool)
zvol_state_t *zv, *zv_next;
char *str;
- str = kmem_zalloc(DISK_NAME_LEN, KM_SLEEP);
+ str = kmem_zalloc(MAXNAMELEN, KM_SLEEP);
if (pool) {
(void) strncpy(str, pool, strlen(pool));
(void) strcat(str, "/");
@@ -1290,7 +1294,7 @@ zvol_remove_minors(const char *pool)
}
}
mutex_exit(&zvol_state_lock);
- kmem_free(str, DISK_NAME_LEN);
+ kmem_free(str, MAXNAMELEN);
}
int