2004-06-12 21:16:10 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2004 Lukas Ertl
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bio.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-09-18 13:44:43 +00:00
|
|
|
#include <sys/kthread.h>
|
2004-06-12 21:16:10 +00:00
|
|
|
#include <sys/libkern.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <geom/geom.h>
|
|
|
|
#include <geom/vinum/geom_vinum_var.h>
|
|
|
|
#include <geom/vinum/geom_vinum.h>
|
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
static void gv_vol_completed_request(struct gv_volume *, struct bio *);
|
|
|
|
static void gv_vol_normal_request(struct gv_volume *, struct bio *);
|
|
|
|
|
2004-06-12 21:16:10 +00:00
|
|
|
static void
|
|
|
|
gv_volume_orphan(struct g_consumer *cp)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
2004-06-16 14:41:04 +00:00
|
|
|
struct gv_volume *v;
|
2004-06-12 21:16:10 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
gp = cp->geom;
|
|
|
|
g_trace(G_T_TOPOLOGY, "gv_volume_orphan(%s)", gp->name);
|
|
|
|
if (cp->acr != 0 || cp->acw != 0 || cp->ace != 0)
|
|
|
|
g_access(cp, -cp->acr, -cp->acw, -cp->ace);
|
|
|
|
error = cp->provider->error;
|
|
|
|
if (error == 0)
|
|
|
|
error = ENXIO;
|
|
|
|
g_detach(cp);
|
|
|
|
g_destroy_consumer(cp);
|
|
|
|
if (!LIST_EMPTY(&gp->consumer))
|
|
|
|
return;
|
2004-06-16 14:41:04 +00:00
|
|
|
v = gp->softc;
|
2004-09-18 13:44:43 +00:00
|
|
|
if (v != NULL) {
|
|
|
|
gv_kill_vol_thread(v);
|
2004-06-18 19:53:33 +00:00
|
|
|
v->geom = NULL;
|
2004-09-18 13:44:43 +00:00
|
|
|
}
|
2004-06-16 14:41:04 +00:00
|
|
|
gp->softc = NULL;
|
2004-06-12 21:16:10 +00:00
|
|
|
g_wither_geom(gp, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We end up here after the requests to our plexes are done. */
|
|
|
|
static void
|
|
|
|
gv_volume_done(struct bio *bp)
|
|
|
|
{
|
2004-09-18 13:44:43 +00:00
|
|
|
struct gv_volume *v;
|
|
|
|
|
|
|
|
v = bp->bio_from->geom->softc;
|
|
|
|
bp->bio_cflags |= GV_BIO_DONE;
|
|
|
|
mtx_lock(&v->bqueue_mtx);
|
2006-01-06 18:03:17 +00:00
|
|
|
bioq_insert_tail(v->bqueue, bp);
|
2004-09-18 13:44:43 +00:00
|
|
|
wakeup(v);
|
|
|
|
mtx_unlock(&v->bqueue_mtx);
|
|
|
|
}
|
2004-06-12 21:16:10 +00:00
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
static void
|
|
|
|
gv_volume_start(struct bio *bp)
|
|
|
|
{
|
|
|
|
struct gv_volume *v;
|
2004-06-12 21:16:10 +00:00
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
switch(bp->bio_cmd) {
|
|
|
|
case BIO_READ:
|
2004-06-12 21:16:10 +00:00
|
|
|
case BIO_WRITE:
|
|
|
|
case BIO_DELETE:
|
2004-09-18 13:44:43 +00:00
|
|
|
break;
|
|
|
|
case BIO_GETATTR:
|
|
|
|
default:
|
|
|
|
g_io_deliver(bp, EOPNOTSUPP);
|
|
|
|
return;
|
|
|
|
}
|
2004-06-12 21:16:10 +00:00
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
v = bp->bio_to->geom->softc;
|
|
|
|
if (v->state != GV_VOL_UP) {
|
|
|
|
g_io_deliver(bp, ENXIO);
|
2004-06-12 21:16:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-09-18 13:44:43 +00:00
|
|
|
|
|
|
|
mtx_lock(&v->bqueue_mtx);
|
2006-01-06 18:03:17 +00:00
|
|
|
bioq_disksort(v->bqueue, bp);
|
2004-09-18 13:44:43 +00:00
|
|
|
wakeup(v);
|
|
|
|
mtx_unlock(&v->bqueue_mtx);
|
2004-06-12 21:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-18 13:44:43 +00:00
|
|
|
gv_vol_worker(void *arg)
|
2004-06-12 21:16:10 +00:00
|
|
|
{
|
2004-09-18 13:44:43 +00:00
|
|
|
struct bio *bp;
|
2004-06-12 21:16:10 +00:00
|
|
|
struct gv_volume *v;
|
2004-09-18 13:44:43 +00:00
|
|
|
|
|
|
|
v = arg;
|
|
|
|
KASSERT(v != NULL, ("NULL v"));
|
|
|
|
mtx_lock(&v->bqueue_mtx);
|
|
|
|
for (;;) {
|
|
|
|
/* We were signaled to exit. */
|
|
|
|
if (v->flags & GV_VOL_THREAD_DIE)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Take the first BIO from our queue. */
|
2006-01-06 18:03:17 +00:00
|
|
|
bp = bioq_takefirst(v->bqueue);
|
|
|
|
if (bp == NULL) {
|
2004-09-18 13:44:43 +00:00
|
|
|
msleep(v, &v->bqueue_mtx, PRIBIO, "-", hz/10);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
mtx_unlock(&v->bqueue_mtx);
|
2004-06-12 21:16:10 +00:00
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
if (bp->bio_cflags & GV_BIO_DONE)
|
|
|
|
gv_vol_completed_request(v, bp);
|
|
|
|
else
|
|
|
|
gv_vol_normal_request(v, bp);
|
|
|
|
|
|
|
|
mtx_lock(&v->bqueue_mtx);
|
2004-06-12 21:16:10 +00:00
|
|
|
}
|
2004-09-18 13:44:43 +00:00
|
|
|
mtx_unlock(&v->bqueue_mtx);
|
|
|
|
v->flags |= GV_VOL_THREAD_DEAD;
|
|
|
|
wakeup(v);
|
|
|
|
|
2007-10-20 23:23:23 +00:00
|
|
|
kproc_exit(ENXIO);
|
2004-09-18 13:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gv_vol_completed_request(struct gv_volume *v, struct bio *bp)
|
|
|
|
{
|
|
|
|
struct bio *pbp;
|
2005-02-23 14:59:14 +00:00
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp, *cp2;
|
2004-09-18 13:44:43 +00:00
|
|
|
|
|
|
|
pbp = bp->bio_parent;
|
|
|
|
|
|
|
|
if (pbp->bio_error == 0)
|
|
|
|
pbp->bio_error = bp->bio_error;
|
|
|
|
|
|
|
|
switch (pbp->bio_cmd) {
|
2004-06-12 21:16:10 +00:00
|
|
|
case BIO_READ:
|
2005-02-23 14:59:14 +00:00
|
|
|
if (bp->bio_error == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (pbp->bio_cflags & GV_BIO_RETRY)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if we have another plex left. */
|
|
|
|
cp = bp->bio_from;
|
|
|
|
gp = cp->geom;
|
|
|
|
cp2 = LIST_NEXT(cp, consumer);
|
|
|
|
if (cp2 == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (LIST_NEXT(cp2, consumer) == NULL)
|
|
|
|
pbp->bio_cflags |= GV_BIO_RETRY;
|
|
|
|
|
|
|
|
g_destroy_bio(bp);
|
|
|
|
pbp->bio_children--;
|
|
|
|
mtx_lock(&v->bqueue_mtx);
|
2006-01-06 18:03:17 +00:00
|
|
|
bioq_disksort(v->bqueue, pbp);
|
2005-02-23 14:59:14 +00:00
|
|
|
mtx_unlock(&v->bqueue_mtx);
|
|
|
|
return;
|
|
|
|
|
2004-06-12 21:16:10 +00:00
|
|
|
case BIO_WRITE:
|
|
|
|
case BIO_DELETE:
|
2005-02-23 14:59:14 +00:00
|
|
|
/* Remember if this write request succeeded. */
|
|
|
|
if (bp->bio_error == 0)
|
|
|
|
pbp->bio_cflags |= GV_BIO_SUCCEED;
|
2004-09-18 13:44:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When the original request is finished, we deliver it. */
|
|
|
|
pbp->bio_inbed++;
|
|
|
|
if (pbp->bio_inbed == pbp->bio_children) {
|
2005-02-23 14:59:14 +00:00
|
|
|
if (pbp->bio_cflags & GV_BIO_SUCCEED)
|
|
|
|
pbp->bio_error = 0;
|
2004-09-18 13:44:43 +00:00
|
|
|
pbp->bio_completed = bp->bio_length;
|
|
|
|
g_io_deliver(pbp, pbp->bio_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_destroy_bio(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gv_vol_normal_request(struct gv_volume *v, struct bio *bp)
|
|
|
|
{
|
2005-07-15 13:38:06 +00:00
|
|
|
struct bio_queue_head queue;
|
2004-09-18 13:44:43 +00:00
|
|
|
struct g_geom *gp;
|
2005-07-15 13:38:06 +00:00
|
|
|
struct gv_plex *p, *lp;
|
|
|
|
struct bio *cbp;
|
2004-09-18 13:44:43 +00:00
|
|
|
|
|
|
|
gp = v->geom;
|
|
|
|
|
|
|
|
switch (bp->bio_cmd) {
|
|
|
|
case BIO_READ:
|
|
|
|
cbp = g_clone_bio(bp);
|
|
|
|
if (cbp == NULL) {
|
2004-06-12 21:16:10 +00:00
|
|
|
g_io_deliver(bp, ENOMEM);
|
|
|
|
return;
|
|
|
|
}
|
2004-09-18 13:44:43 +00:00
|
|
|
cbp->bio_done = gv_volume_done;
|
2005-02-23 14:59:14 +00:00
|
|
|
/*
|
|
|
|
* Try to find a good plex where we can send the request to.
|
|
|
|
* The plex either has to be up, or it's a degraded RAID5 plex.
|
|
|
|
*/
|
2005-07-15 13:38:06 +00:00
|
|
|
lp = v->last_read_plex;
|
|
|
|
if (lp == NULL)
|
|
|
|
lp = LIST_FIRST(&v->plexes);
|
|
|
|
p = LIST_NEXT(lp, in_volume);
|
|
|
|
do {
|
|
|
|
if (p == NULL)
|
|
|
|
p = LIST_FIRST(&v->plexes);
|
2005-02-23 14:59:14 +00:00
|
|
|
if ((p->state > GV_PLEX_DEGRADED) ||
|
|
|
|
(p->state >= GV_PLEX_DEGRADED &&
|
|
|
|
p->org == GV_PLEX_RAID5))
|
2004-09-18 13:44:43 +00:00
|
|
|
break;
|
2005-07-15 13:38:06 +00:00
|
|
|
p = LIST_NEXT(p, in_volume);
|
|
|
|
} while (p != lp);
|
|
|
|
|
|
|
|
if (p == NULL ||
|
|
|
|
(p->org == GV_PLEX_RAID5 && p->state < GV_PLEX_DEGRADED) ||
|
2005-08-22 23:24:26 +00:00
|
|
|
(p->org != GV_PLEX_RAID5 && p->state <= GV_PLEX_DEGRADED)) {
|
2005-02-23 14:59:14 +00:00
|
|
|
g_destroy_bio(cbp);
|
|
|
|
bp->bio_children--;
|
|
|
|
g_io_deliver(bp, ENXIO);
|
|
|
|
return;
|
|
|
|
}
|
2004-09-18 13:44:43 +00:00
|
|
|
g_io_request(cbp, p->consumer);
|
2005-07-15 13:38:06 +00:00
|
|
|
v->last_read_plex = p;
|
2004-09-18 13:44:43 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BIO_WRITE:
|
|
|
|
case BIO_DELETE:
|
2005-07-15 13:38:06 +00:00
|
|
|
bioq_init(&queue);
|
2004-09-18 13:44:43 +00:00
|
|
|
LIST_FOREACH(p, &v->plexes, in_volume) {
|
|
|
|
if (p->state < GV_PLEX_DEGRADED)
|
|
|
|
continue;
|
|
|
|
cbp = g_clone_bio(bp);
|
2005-07-15 13:38:06 +00:00
|
|
|
if (cbp == NULL) {
|
|
|
|
for (cbp = bioq_first(&queue); cbp != NULL;
|
|
|
|
cbp = bioq_first(&queue)) {
|
|
|
|
bioq_remove(&queue, cbp);
|
|
|
|
g_destroy_bio(cbp);
|
|
|
|
}
|
|
|
|
if (bp->bio_error == 0)
|
|
|
|
bp->bio_error = ENOMEM;
|
|
|
|
g_io_deliver(bp, bp->bio_error);
|
|
|
|
return;
|
2004-09-18 13:44:43 +00:00
|
|
|
}
|
2005-07-15 13:38:06 +00:00
|
|
|
bioq_insert_tail(&queue, cbp);
|
|
|
|
cbp->bio_done = gv_volume_done;
|
|
|
|
cbp->bio_caller1 = p->consumer;
|
2004-09-18 13:44:43 +00:00
|
|
|
}
|
|
|
|
/* Fire off all sub-requests. */
|
2005-07-15 13:38:06 +00:00
|
|
|
for (cbp = bioq_first(&queue); cbp != NULL;
|
|
|
|
cbp = bioq_first(&queue)) {
|
|
|
|
bioq_remove(&queue, cbp);
|
|
|
|
g_io_request(cbp, cbp->bio_caller1);
|
2004-09-18 13:44:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-06-12 21:16:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gv_volume_access(struct g_provider *pp, int dr, int dw, int de)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_consumer *cp, *cp2;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
gp = pp->geom;
|
|
|
|
|
|
|
|
error = ENXIO;
|
|
|
|
LIST_FOREACH(cp, &gp->consumer, consumer) {
|
|
|
|
error = g_access(cp, dr, dw, de);
|
|
|
|
if (error) {
|
|
|
|
LIST_FOREACH(cp2, &gp->consumer, consumer) {
|
|
|
|
if (cp == cp2)
|
|
|
|
break;
|
|
|
|
g_access(cp2, -dr, -dw, -de);
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct g_geom *
|
|
|
|
gv_volume_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp2;
|
2004-08-26 21:04:41 +00:00
|
|
|
struct g_consumer *cp, *ocp;
|
2004-06-12 21:16:10 +00:00
|
|
|
struct gv_softc *sc;
|
|
|
|
struct gv_volume *v;
|
|
|
|
struct gv_plex *p;
|
2004-08-26 21:04:41 +00:00
|
|
|
int error, first;
|
2004-06-12 21:16:10 +00:00
|
|
|
|
|
|
|
g_trace(G_T_TOPOLOGY, "gv_volume_taste(%s, %s)", mp->name, pp->name);
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
/* First, find the VINUM class and its associated geom. */
|
|
|
|
gp = find_vinum_geom();
|
|
|
|
if (gp == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
sc = gp->softc;
|
|
|
|
KASSERT(sc != NULL, ("gv_volume_taste: NULL sc"));
|
|
|
|
|
|
|
|
gp = pp->geom;
|
|
|
|
|
|
|
|
/* We only want to attach to plexes. */
|
|
|
|
if (strcmp(gp->class->name, "VINUMPLEX"))
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
first = 0;
|
|
|
|
p = gp->softc;
|
2005-01-19 14:08:16 +00:00
|
|
|
|
|
|
|
/* Let's see if the volume this plex wants is already configured. */
|
2004-06-12 21:16:10 +00:00
|
|
|
v = gv_find_vol(sc, p->volume);
|
|
|
|
if (v == NULL)
|
|
|
|
return (NULL);
|
|
|
|
if (v->geom == NULL) {
|
|
|
|
gp = g_new_geomf(mp, "%s", p->volume);
|
|
|
|
gp->start = gv_volume_start;
|
|
|
|
gp->orphan = gv_volume_orphan;
|
|
|
|
gp->access = gv_volume_access;
|
|
|
|
gp->softc = v;
|
|
|
|
first++;
|
2005-01-19 14:08:16 +00:00
|
|
|
} else
|
|
|
|
gp = v->geom;
|
|
|
|
|
2006-01-06 18:03:17 +00:00
|
|
|
/* Create bio queue, queue mutex, and worker thread, if necessary. */
|
|
|
|
if (v->bqueue == NULL) {
|
|
|
|
v->bqueue = g_malloc(sizeof(struct bio_queue_head),
|
|
|
|
M_WAITOK | M_ZERO);
|
|
|
|
bioq_init(v->bqueue);
|
|
|
|
}
|
2005-01-19 14:08:16 +00:00
|
|
|
if (mtx_initialized(&v->bqueue_mtx) == 0)
|
2004-09-18 13:44:43 +00:00
|
|
|
mtx_init(&v->bqueue_mtx, "gv_plex", NULL, MTX_DEF);
|
2005-01-19 14:08:16 +00:00
|
|
|
|
|
|
|
if (!(v->flags & GV_VOL_THREAD_ACTIVE)) {
|
2007-10-20 23:23:23 +00:00
|
|
|
kproc_create(gv_vol_worker, v, NULL, 0, 0, "gv_v %s",
|
2004-09-18 13:44:43 +00:00
|
|
|
v->name);
|
|
|
|
v->flags |= GV_VOL_THREAD_ACTIVE;
|
2005-01-19 14:08:16 +00:00
|
|
|
}
|
2004-06-12 21:16:10 +00:00
|
|
|
|
2004-08-26 21:04:41 +00:00
|
|
|
/*
|
|
|
|
* Create a new consumer and attach it to the plex geom. Since this
|
|
|
|
* volume might already have a plex attached, we need to adjust the
|
|
|
|
* access counts of the new consumer.
|
|
|
|
*/
|
|
|
|
ocp = LIST_FIRST(&gp->consumer);
|
2004-06-12 21:16:10 +00:00
|
|
|
cp = g_new_consumer(gp);
|
|
|
|
g_attach(cp, pp);
|
2004-08-26 21:04:41 +00:00
|
|
|
if ((ocp != NULL) && (ocp->acr > 0 || ocp->acw > 0 || ocp->ace > 0)) {
|
|
|
|
error = g_access(cp, ocp->acr, ocp->acw, ocp->ace);
|
|
|
|
if (error) {
|
|
|
|
printf("GEOM_VINUM: failed g_access %s -> %s; "
|
|
|
|
"errno %d\n", v->name, p->name, error);
|
|
|
|
g_detach(cp);
|
|
|
|
g_destroy_consumer(cp);
|
|
|
|
if (first)
|
|
|
|
g_destroy_geom(gp);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-12 21:16:10 +00:00
|
|
|
p->consumer = cp;
|
|
|
|
|
|
|
|
if (p->vol_sc != v) {
|
|
|
|
p->vol_sc = v;
|
|
|
|
v->plexcount++;
|
|
|
|
LIST_INSERT_HEAD(&v->plexes, p, in_volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We need to setup a new VINUMVOLUME geom. */
|
|
|
|
if (first) {
|
|
|
|
pp2 = g_new_providerf(gp, "gvinum/%s", v->name);
|
|
|
|
pp2->mediasize = pp->mediasize;
|
|
|
|
pp2->sectorsize = pp->sectorsize;
|
|
|
|
g_error_provider(pp2, 0);
|
|
|
|
v->size = pp2->mediasize;
|
|
|
|
v->geom = gp;
|
|
|
|
return (gp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
gv_volume_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
|
|
|
struct g_geom *gp)
|
|
|
|
{
|
2004-09-18 13:44:43 +00:00
|
|
|
struct gv_volume *v;
|
|
|
|
|
2004-06-12 21:16:10 +00:00
|
|
|
g_trace(G_T_TOPOLOGY, "gv_volume_destroy_geom: %s", gp->name);
|
|
|
|
g_topology_assert();
|
2004-06-18 19:53:33 +00:00
|
|
|
|
2004-09-18 13:44:43 +00:00
|
|
|
v = gp->softc;
|
|
|
|
gv_kill_vol_thread(v);
|
2004-06-12 21:16:10 +00:00
|
|
|
g_wither_geom(gp, ENXIO);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define VINUMVOLUME_CLASS_NAME "VINUMVOLUME"
|
|
|
|
|
|
|
|
static struct g_class g_vinum_volume_class = {
|
|
|
|
.name = VINUMVOLUME_CLASS_NAME,
|
2004-08-08 07:57:53 +00:00
|
|
|
.version = G_VERSION,
|
2004-06-12 21:16:10 +00:00
|
|
|
.taste = gv_volume_taste,
|
|
|
|
.destroy_geom = gv_volume_destroy_geom,
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_GEOM_CLASS(g_vinum_volume_class, g_vinum_volume);
|