From d30f29867e16407963e980d657eba0b67822d3f2 Mon Sep 17 00:00:00 2001 From: Lukas Ertl Date: Wed, 18 Aug 2004 20:34:45 +0000 Subject: [PATCH] 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. --- sys/geom/vinum/geom_vinum_drive.c | 38 ++++++++----------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c index a5d2b594628a..12929fbcd569 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;