mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
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.
This commit is contained in:
parent
badcc39b73
commit
d30f29867e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133983
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user