Clean up allocated ressources when destroying the main vinum geom.
This commit is contained in:
parent
3a20dac2f5
commit
b7f1bee2cf
@ -520,6 +520,9 @@ gv_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
|
|||||||
struct g_geom *gp2;
|
struct g_geom *gp2;
|
||||||
struct gv_softc *sc;
|
struct gv_softc *sc;
|
||||||
struct gv_drive *d, *d2;
|
struct gv_drive *d, *d2;
|
||||||
|
struct gv_plex *p, *p2;
|
||||||
|
struct gv_sd *s, *s2;
|
||||||
|
struct gv_volume *v, *v2;
|
||||||
struct gv_freelist *fl, *fl2;
|
struct gv_freelist *fl, *fl2;
|
||||||
|
|
||||||
g_trace(G_T_TOPOLOGY, "gv_destroy_geom: %s", gp->name);
|
g_trace(G_T_TOPOLOGY, "gv_destroy_geom: %s", gp->name);
|
||||||
@ -539,7 +542,9 @@ gv_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
|
|||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clean up and deallocate what we allocated. */
|
||||||
LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) {
|
LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) {
|
||||||
|
LIST_REMOVE(d, drive);
|
||||||
g_free(d->hdr);
|
g_free(d->hdr);
|
||||||
d->hdr = NULL;
|
d->hdr = NULL;
|
||||||
LIST_FOREACH_SAFE(fl, &d->freelist, freelist, fl2) {
|
LIST_FOREACH_SAFE(fl, &d->freelist, freelist, fl2) {
|
||||||
@ -548,11 +553,40 @@ gv_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
|
|||||||
g_free(fl);
|
g_free(fl);
|
||||||
fl = NULL;
|
fl = NULL;
|
||||||
}
|
}
|
||||||
LIST_REMOVE(d, drive);
|
d->geom->softc = NULL;
|
||||||
|
g_free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIST_FOREACH_SAFE(s, &sc->subdisks, sd, s2) {
|
||||||
|
LIST_REMOVE(s, sd);
|
||||||
|
s->drive_sc = NULL;
|
||||||
|
s->plex_sc = NULL;
|
||||||
|
s->provider = NULL;
|
||||||
|
s->consumer = NULL;
|
||||||
|
g_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIST_FOREACH_SAFE(p, &sc->plexes, plex, p2) {
|
||||||
|
LIST_REMOVE(p, plex);
|
||||||
|
gv_kill_thread(p);
|
||||||
|
p->vol_sc = NULL;
|
||||||
|
p->geom->softc = NULL;
|
||||||
|
p->provider = NULL;
|
||||||
|
p->consumer = NULL;
|
||||||
|
if (p->org == GV_PLEX_RAID5) {
|
||||||
|
mtx_destroy(&p->worklist_mtx);
|
||||||
|
}
|
||||||
|
g_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIST_FOREACH_SAFE(v, &sc->volumes, volume, v2) {
|
||||||
|
LIST_REMOVE(v, volume);
|
||||||
|
v->geom->softc = NULL;
|
||||||
|
g_free(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
gp->softc = NULL;
|
||||||
g_free(sc);
|
g_free(sc);
|
||||||
sc = NULL;
|
|
||||||
g_wither_geom(gp, ENXIO);
|
g_wither_geom(gp, ENXIO);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -281,13 +281,15 @@ gv_drive_orphan(struct g_consumer *cp)
|
|||||||
if (!LIST_EMPTY(&gp->consumer))
|
if (!LIST_EMPTY(&gp->consumer))
|
||||||
return;
|
return;
|
||||||
d = gp->softc;
|
d = gp->softc;
|
||||||
printf("gvinum: lost drive '%s'\n", d->name);
|
if (d != NULL) {
|
||||||
d->geom = NULL;
|
printf("gvinum: lost drive '%s'\n", d->name);
|
||||||
LIST_FOREACH(s, &d->subdisks, from_drive) {
|
d->geom = NULL;
|
||||||
s->provider = NULL;
|
LIST_FOREACH(s, &d->subdisks, from_drive) {
|
||||||
s->consumer = NULL;
|
s->provider = NULL;
|
||||||
|
s->consumer = NULL;
|
||||||
|
}
|
||||||
|
gv_set_drive_state(d, GV_DRIVE_DOWN, GV_SETSTATE_FORCE);
|
||||||
}
|
}
|
||||||
gv_set_drive_state(d, GV_DRIVE_DOWN, GV_SETSTATE_FORCE);
|
|
||||||
gp->softc = NULL;
|
gp->softc = NULL;
|
||||||
g_wither_geom(gp, error);
|
g_wither_geom(gp, error);
|
||||||
}
|
}
|
||||||
@ -465,12 +467,9 @@ static int
|
|||||||
gv_drive_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
gv_drive_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
||||||
struct g_geom *gp)
|
struct g_geom *gp)
|
||||||
{
|
{
|
||||||
/*struct gv_drive *d;*/
|
|
||||||
|
|
||||||
g_trace(G_T_TOPOLOGY, "gv_drive_destroy_geom: %s", gp->name);
|
g_trace(G_T_TOPOLOGY, "gv_drive_destroy_geom: %s", gp->name);
|
||||||
g_topology_assert();
|
g_topology_assert();
|
||||||
|
|
||||||
/* g_free(sc); */
|
|
||||||
g_wither_geom(gp, ENXIO);
|
g_wither_geom(gp, ENXIO);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,13 @@ gv_plex_orphan(struct g_consumer *cp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
p = gp->softc;
|
p = gp->softc;
|
||||||
gv_kill_thread(p);
|
if (p != NULL) {
|
||||||
p->geom = NULL;
|
gv_kill_thread(p);
|
||||||
|
p->geom = NULL;
|
||||||
|
p->provider = NULL;
|
||||||
|
p->consumer = NULL;
|
||||||
|
}
|
||||||
gp->softc = NULL;
|
gp->softc = NULL;
|
||||||
p->provider = NULL;
|
|
||||||
p->consumer = NULL;
|
|
||||||
g_wither_geom(gp, error);
|
g_wither_geom(gp, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ gv_volume_orphan(struct g_consumer *cp)
|
|||||||
if (!LIST_EMPTY(&gp->consumer))
|
if (!LIST_EMPTY(&gp->consumer))
|
||||||
return;
|
return;
|
||||||
v = gp->softc;
|
v = gp->softc;
|
||||||
v->geom = NULL;
|
if (v != NULL)
|
||||||
|
v->geom = NULL;
|
||||||
gp->softc = NULL;
|
gp->softc = NULL;
|
||||||
g_wither_geom(gp, error);
|
g_wither_geom(gp, error);
|
||||||
}
|
}
|
||||||
@ -243,11 +244,7 @@ gv_volume_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
|||||||
{
|
{
|
||||||
g_trace(G_T_TOPOLOGY, "gv_volume_destroy_geom: %s", gp->name);
|
g_trace(G_T_TOPOLOGY, "gv_volume_destroy_geom: %s", gp->name);
|
||||||
g_topology_assert();
|
g_topology_assert();
|
||||||
/*
|
|
||||||
if (gp->softc != NULL)
|
|
||||||
g_free(gp->softc);
|
|
||||||
gp->softc = NULL;
|
|
||||||
*/
|
|
||||||
g_wither_geom(gp, ENXIO);
|
g_wither_geom(gp, ENXIO);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user