summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorle <le@FreeBSD.org>2004-08-18 20:34:45 +0000
committerle <le@FreeBSD.org>2004-08-18 20:34:45 +0000
commitfc5a15a34b40a913a09a0ee8850ebbfc9202d09c (patch)
tree7fe949d63bae77f50e700a815e1b084762e3287b
parent8a11d8ccf0a1847a37b7d0d8431615c6bd6df93e (diff)
downloadFreeBSD-src-fc5a15a34b40a913a09a0ee8850ebbfc9202d09c.zip
FreeBSD-src-fc5a15a34b40a913a09a0ee8850ebbfc9202d09c.tar.gz
Fix a stupid bug in the drive taste function: when checking if a
drive is known to the configuration check also if it already has a geom. Without this check several needless geoms are created and valid configuration data was overwritten. This change obsoletes the need for a separate geom to taste an offered provider and the consumer doesn't need to be opened with the exclusive bit set.
-rw-r--r--sys/geom/vinum/geom_vinum_drive.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c
index a5d2b59..12929fb 100644
--- a/sys/geom/vinum/geom_vinum_drive.c
+++ b/sys/geom/vinum/geom_vinum_drive.c
@@ -296,12 +296,6 @@ gv_drive_orphan(struct g_consumer *cp)
g_wither_geom(gp, error);
}
-static void
-gv_drive_taste_orphan(struct g_consumer *cp)
-{
- KASSERT(1 == 0, ("gv_drive_taste_orphan called: %s", cp->geom->name));
-}
-
static struct g_geom *
gv_drive_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
{
@@ -331,7 +325,10 @@ gv_drive_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
sc = gp2->softc;
gp = g_new_geomf(mp, "%s.vinumdrive", pp->name);
- gp->orphan = gv_drive_taste_orphan;
+ gp->start = gv_drive_start;
+ gp->orphan = gv_drive_orphan;
+ gp->access = gv_drive_access;
+ gp->start = gv_drive_start;
cp = g_new_consumer(gp);
g_attach(cp, pp);
@@ -371,15 +368,15 @@ gv_drive_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
gv_parse_config(sc, buf, 1);
g_free(buf);
- g_access(cp, -1, 0, 0);
- g_detach(cp);
- g_wither_geom(gp, ENXIO);
- gp = NULL;
-
d = gv_find_drive(sc, vhdr->label.name);
/* We already know about this drive. */
if (d != NULL) {
+ /* Check if this drive already has a geom. */
+ if (d->geom != NULL) {
+ g_topology_unlock();
+ break;
+ }
bcopy(vhdr, d->hdr, sizeof(*vhdr));
/* This is a new drive. */
@@ -405,22 +402,7 @@ gv_drive_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
LIST_INSERT_HEAD(&sc->drives, d, drive);
}
- gp = g_new_geomf(mp, "%s.vinumdrive", pp->name);
- gp->start = gv_drive_start;
- gp->orphan = gv_drive_orphan;
- gp->access = gv_drive_access;
- gp->start = gv_drive_start;
-
- cp = g_new_consumer(gp);
- g_attach(cp, pp);
- error = g_access(cp, 1, 1, 1);
- if (error) {
- g_free(vhdr);
- g_detach(cp);
- g_destroy_consumer(cp);
- g_destroy_geom(gp);
- return (NULL);
- }
+ g_access(cp, -1, 0, 0);
gp->softc = d;
d->geom = gp;
OpenPOWER on IntegriCloud