FreeBSD/sys/geom/vinum/geom_vinum_subr.c
/* Detach a plex from a volume. */
Detach a plex from a volume.
Detach a plex from a volume .
int
gv_detach_plex(struct gv_plex *p, int flags)
{
	struct gv_volume *v;
	g_topology_assert();
	v = p->vol_sc;
	if (v == NULL) {
		G_VINUM_DEBUG(1, "unable to detach %s: already detached",
		    p->name);
		return (0); 
	}
	if (!(flags & GV_FLAG_F) && (gv_provider_is_open(v->provider) ||
	    p->state == GV_PLEX_UP)) {
		G_VINUM_DEBUG(1, "unable to detach %s: volume %s is busy",
		    p->name, p->volume);
		return (GV_ERR_ISBUSY);
	}
	v->plexcount--;
	v->last_read_plex = NULL; 
	LIST_REMOVE(p, in_volume);
	p->vol_sc = NULL;
	memset(p->volume, 0, GV_MAXVOLNAME);
	gv_update_vol_size(v, gv_vol_size(v));
	gv_save_config(p->vinumconf);
	return (0);
}
int gv_detach_plex ( struct gv_plex * p , int flags ) { struct gv_volume * v ; g_topology_assert ( ) ; v = p -> vol_sc ; if ( v == NULL ) { G_VINUM_DEBUG ( 1 , " " , p -> name ) ; return ( 0 ) ; } if ( ! ( flags & GV_FLAG_F ) && ( gv_provider_is_open ( v -> provider ) || p -> state == GV_PLEX_UP ) ) { G_VINUM_DEBUG ( 1 , " " , p -> name , p -> volume ) ; return ( GV_ERR_ISBUSY ) ; } v -> plexcount -- ; v -> last_read_plex = NULL ; LIST_REMOVE ( p , in_volume ) ; p -> vol_sc = NULL ; memset ( p -> volume , 0 , GV_MAXVOLNAME ) ; gv_update_vol_size ( v , gv_vol_size ( v ) ) ; gv_save_config ( p -> vinumconf ) ; return ( 0 ) ; }
Detach a plex from a volume.
Detach a plex from a volume .
/* Not an error. */ /*
	 * Only proceed if forced or volume inactive.
	 */ /* Make sure someone don't read us when gone. */