示例#1
0
文件: zvol.c 项目: alek-p/zfs
/* Remove minor for this specific snapshot only */
static void
zvol_remove_minor_impl(const char *name)
{
	zvol_state_t *zv, *zv_next;

	if (zvol_inhibit_dev)
		return;

	if (strchr(name, '@') == NULL)
		return;

	mutex_enter(&zvol_state_lock);

	for (zv = list_head(&zvol_state_list); zv != NULL; zv = zv_next) {
		zv_next = list_next(&zvol_state_list, zv);

		if (strcmp(zv->zv_name, name) == 0) {
			/* If in use, leave alone */
			if (zv->zv_open_count > 0)
				continue;
			zvol_remove(zv);
			zvol_free(zv);
			break;
		}
	}

	mutex_exit(&zvol_state_lock);
}
示例#2
0
文件: zvol.c 项目: alek-p/zfs
/*
 * Remove minors for specified dataset including children and snapshots.
 */
static void
zvol_remove_minors_impl(const char *name)
{
	zvol_state_t *zv, *zv_next;
	int namelen = ((name) ? strlen(name) : 0);

	if (zvol_inhibit_dev)
		return;

	mutex_enter(&zvol_state_lock);

	for (zv = list_head(&zvol_state_list); zv != NULL; zv = zv_next) {
		zv_next = list_next(&zvol_state_list, zv);

		if (name == NULL || strcmp(zv->zv_name, name) == 0 ||
		    (strncmp(zv->zv_name, name, namelen) == 0 &&
		    (zv->zv_name[namelen] == '/' ||
		    zv->zv_name[namelen] == '@'))) {

			/* If in use, leave alone */
			if (zv->zv_open_count > 0)
				continue;

			zvol_remove(zv);
			zvol_free(zv);
		}
	}

	mutex_exit(&zvol_state_lock);
}
示例#3
0
/*
 * Remove minors for specified pool, if pool is NULL remove all minors.
 */
void
zvol_remove_minors(const char *pool)
{
	zvol_state_t *zv, *zv_next;
	char *str;

	if (zvol_inhibit_dev)
		return;

	str = kmem_zalloc(MAXNAMELEN, KM_SLEEP);
	if (pool) {
		(void) strncpy(str, pool, strlen(pool));
		(void) strcat(str, "/");
	}

	mutex_enter(&zvol_state_lock);
	for (zv = list_head(&zvol_state_list); zv != NULL; zv = zv_next) {
		zv_next = list_next(&zvol_state_list, zv);

		if (pool == NULL || !strncmp(str, zv->zv_name, strlen(str))) {
			zvol_remove(zv);
			zvol_free(zv);
		}
	}
	mutex_exit(&zvol_state_lock);
	kmem_free(str, MAXNAMELEN);
}
示例#4
0
static int
__zvol_remove_minor(const char *name)
{
	zvol_state_t *zv;

	ASSERT(MUTEX_HELD(&zvol_state_lock));

	zv = zvol_find_by_name(name);
	if (zv == NULL)
		return (ENXIO);

	if (zv->zv_open_count > 0)
		return (EBUSY);

	zvol_remove(zv);
	zvol_free(zv);

	return (0);
}
示例#5
0
文件: zvol.c 项目: Acidburn0zzz/zfs
/*
 * Remove minors for specified dataset including children and snapshots.
 */
void
zvol_remove_minors(const char *name)
{
	zvol_state_t *zv, *zv_next;
	int namelen = ((name) ? strlen(name) : 0);

	if (zvol_inhibit_dev)
		return;

	mutex_enter(&zvol_state_lock);

	for (zv = list_head(&zvol_state_list); zv != NULL; zv = zv_next) {
		zv_next = list_next(&zvol_state_list, zv);

		if (name == NULL || strcmp(zv->zv_name, name) == 0 ||
		    (strncmp(zv->zv_name, name, namelen) == 0 &&
		    zv->zv_name[namelen] == '/')) {
			zvol_remove(zv);
			zvol_free(zv);
		}
	}

	mutex_exit(&zvol_state_lock);
}