FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
/*
 * Remove minor node for the specified volume.
 */
Remove minor node for the specified volume.
Remove minor node for the specified volume .
static int
zvol_remove_zv(zvol_state_t *zv)
{
#ifdef illumos
	char nmbuf[20];
	minor_t minor = zv->zv_minor;
#endif
	ASSERT(MUTEX_HELD(&zfsdev_state_lock));
	if (zv->zv_total_opens != 0)
		return (SET_ERROR(EBUSY));
#ifdef illumos
	(void) snprintf(nmbuf, sizeof (nmbuf), "%u,raw", minor);
	ddi_remove_minor_node(zfs_dip, nmbuf);
	(void) snprintf(nmbuf, sizeof (nmbuf), "%u", minor);
	ddi_remove_minor_node(zfs_dip, nmbuf);
#else
	ZFS_LOG(1, "ZVOL %s destroyed.", zv->zv_name);
	LIST_REMOVE(zv, zv_links);
	if (zv->zv_volmode == ZFS_VOLMODE_GEOM) {
		g_topology_lock();
		zvol_geom_destroy(zv);
		g_topology_unlock();
	} else if (zv->zv_volmode == ZFS_VOLMODE_DEV)
		destroy_dev(zv->zv_dev);
#endif
	avl_destroy(&zv->zv_znode.z_range_avl);
	mutex_destroy(&zv->zv_znode.z_range_lock);
	kmem_free(zv, sizeof (zvol_state_t));
#ifdef illumos
	ddi_soft_state_free(zfsdev_state, minor);
#endif
	zvol_minors--;
	return (0);
}
static int zvol_remove_zv ( zvol_state_t * zv ) { #ifdef illumos char nmbuf [ 20 ] ; minor_t minor = zv -> zv_minor ; #endif ASSERT ( MUTEX_HELD ( & zfsdev_state_lock ) ) ; if ( zv -> zv_total_opens != 0 ) return ( SET_ERROR ( EBUSY ) ) ; #ifdef illumos ( void ) snprintf ( nmbuf , sizeof ( nmbuf ) , " " , minor ) ; ddi_remove_minor_node ( zfs_dip , nmbuf ) ; ( void ) snprintf ( nmbuf , sizeof ( nmbuf ) , " " , minor ) ; ddi_remove_minor_node ( zfs_dip , nmbuf ) ; #else ZFS_LOG ( 1 , " " , zv -> zv_name ) ; LIST_REMOVE ( zv , zv_links ) ; if ( zv -> zv_volmode == ZFS_VOLMODE_GEOM ) { g_topology_lock ( ) ; zvol_geom_destroy ( zv ) ; g_topology_unlock ( ) ; } else if ( zv -> zv_volmode == ZFS_VOLMODE_DEV ) destroy_dev ( zv -> zv_dev ) ; #endif avl_destroy ( & zv -> zv_znode . z_range_avl ) ; mutex_destroy ( & zv -> zv_znode . z_range_lock ) ; kmem_free ( zv , sizeof ( zvol_state_t ) ) ; #ifdef illumos ddi_soft_state_free ( zfsdev_state , minor ) ; #endif zvol_minors -- ; return ( 0 ) ; }
Remove minor node for the specified volume.
Remove minor node for the specified volume .