summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorle <le@FreeBSD.org>2004-06-18 19:53:33 +0000
committerle <le@FreeBSD.org>2004-06-18 19:53:33 +0000
commitb7f1bee2cf9b05ab722e1afbc5292becbd9075f8 (patch)
treec2b00455cfce196919f914d1a51ff3ed4f7d26c3 /sys/geom
parent3a20dac2f54d6a7e89c05998cfa171b1809a111d (diff)
downloadFreeBSD-src-b7f1bee2cf9b05ab722e1afbc5292becbd9075f8.zip
FreeBSD-src-b7f1bee2cf9b05ab722e1afbc5292becbd9075f8.tar.gz
Clean up allocated ressources when destroying the main vinum geom.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/vinum/geom_vinum.c38
-rw-r--r--sys/geom/vinum/geom_vinum_drive.c17
-rw-r--r--sys/geom/vinum/geom_vinum_plex.c10
-rw-r--r--sys/geom/vinum/geom_vinum_volume.c9
4 files changed, 53 insertions, 21 deletions
diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c
index 44a8061..6ede025 100644
--- a/sys/geom/vinum/geom_vinum.c
+++ b/sys/geom/vinum/geom_vinum.c
@@ -520,6 +520,9 @@ gv_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
struct g_geom *gp2;
struct gv_softc *sc;
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;
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);
}
+ /* Clean up and deallocate what we allocated. */
LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) {
+ LIST_REMOVE(d, drive);
g_free(d->hdr);
d->hdr = NULL;
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);
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);
- sc = NULL;
g_wither_geom(gp, ENXIO);
return (0);
}
diff --git a/sys/geom/vinum/geom_vinum_drive.c b/sys/geom/vinum/geom_vinum_drive.c
index 5d3a381..b3a3325 100644
--- a/sys/geom/vinum/geom_vinum_drive.c
+++ b/sys/geom/vinum/geom_vinum_drive.c
@@ -281,13 +281,15 @@ gv_drive_orphan(struct g_consumer *cp)
if (!LIST_EMPTY(&gp->consumer))
return;
d = gp->softc;
- printf("gvinum: lost drive '%s'\n", d->name);
- d->geom = NULL;
- LIST_FOREACH(s, &d->subdisks, from_drive) {
- s->provider = NULL;
- s->consumer = NULL;
+ if (d != NULL) {
+ printf("gvinum: lost drive '%s'\n", d->name);
+ d->geom = NULL;
+ LIST_FOREACH(s, &d->subdisks, from_drive) {
+ 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;
g_wither_geom(gp, error);
}
@@ -465,12 +467,9 @@ static int
gv_drive_destroy_geom(struct gctl_req *req, struct g_class *mp,
struct g_geom *gp)
{
- /*struct gv_drive *d;*/
-
g_trace(G_T_TOPOLOGY, "gv_drive_destroy_geom: %s", gp->name);
g_topology_assert();
- /* g_free(sc); */
g_wither_geom(gp, ENXIO);
return (0);
}
diff --git a/sys/geom/vinum/geom_vinum_plex.c b/sys/geom/vinum/geom_vinum_plex.c
index beceee0..1887366 100644
--- a/sys/geom/vinum/geom_vinum_plex.c
+++ b/sys/geom/vinum/geom_vinum_plex.c
@@ -66,11 +66,13 @@ gv_plex_orphan(struct g_consumer *cp)
return;
p = gp->softc;
- gv_kill_thread(p);
- p->geom = NULL;
+ if (p != NULL) {
+ gv_kill_thread(p);
+ p->geom = NULL;
+ p->provider = NULL;
+ p->consumer = NULL;
+ }
gp->softc = NULL;
- p->provider = NULL;
- p->consumer = NULL;
g_wither_geom(gp, error);
}
diff --git a/sys/geom/vinum/geom_vinum_volume.c b/sys/geom/vinum/geom_vinum_volume.c
index c39d1e4..7f4216a 100644
--- a/sys/geom/vinum/geom_vinum_volume.c
+++ b/sys/geom/vinum/geom_vinum_volume.c
@@ -62,7 +62,8 @@ gv_volume_orphan(struct g_consumer *cp)
if (!LIST_EMPTY(&gp->consumer))
return;
v = gp->softc;
- v->geom = NULL;
+ if (v != NULL)
+ v->geom = NULL;
gp->softc = NULL;
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_topology_assert();
-/*
- if (gp->softc != NULL)
- g_free(gp->softc);
- gp->softc = NULL;
-*/
+
g_wither_geom(gp, ENXIO);
return (0);
}
OpenPOWER on IntegriCloud