summaryrefslogtreecommitdiffstats
path: root/sys/geom/raid3
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-04-28 11:52:45 +0000
committerpjd <pjd@FreeBSD.org>2006-04-28 11:52:45 +0000
commit4b38e5bbca25f143cbf615b8c7fe1f7873ba1e6c (patch)
tree0cb0e26a9f5e6944e85e6f025d72309556949514 /sys/geom/raid3
parentec0853115317e980cb184dcfcfca0a39f1d4a7a9 (diff)
downloadFreeBSD-src-4b38e5bbca25f143cbf615b8c7fe1f7873ba1e6c.zip
FreeBSD-src-4b38e5bbca25f143cbf615b8c7fe1f7873ba1e6c.tar.gz
Be sure to not destroy device twice. This is not possible in theory, but
with this change there is even no theoretical race. MFC after: 2 weeks
Diffstat (limited to 'sys/geom/raid3')
-rw-r--r--sys/geom/raid3/g_raid3.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c
index 71a8399..3efa279 100644
--- a/sys/geom/raid3/g_raid3.c
+++ b/sys/geom/raid3/g_raid3.c
@@ -602,12 +602,10 @@ g_raid3_destroy_device(struct g_raid3_softc *sc)
}
}
callout_drain(&sc->sc_callout);
- gp->softc = NULL;
cp = LIST_FIRST(&sc->sc_sync.ds_geom->consumer);
g_topology_lock();
if (cp != NULL)
g_raid3_disconnect_consumer(sc, cp);
- sc->sc_sync.ds_geom->softc = NULL;
g_wither_geom(sc->sc_sync.ds_geom, ENXIO);
G_RAID3_DEBUG(0, "Device %s destroyed.", gp->name);
g_wither_geom(gp, ENXIO);
@@ -1876,6 +1874,8 @@ g_raid3_can_destroy(struct g_raid3_softc *sc)
g_topology_assert();
gp = sc->sc_geom;
+ if (gp->softc == NULL)
+ return (1);
LIST_FOREACH(cp, &gp->consumer, consumer) {
if (g_raid3_is_busy(sc, cp))
return (0);
@@ -1909,6 +1909,8 @@ g_raid3_try_destroy(struct g_raid3_softc *sc)
g_topology_unlock();
return (0);
}
+ sc->sc_geom->softc = NULL;
+ sc->sc_sync.ds_geom->softc = NULL;
if ((sc->sc_flags & G_RAID3_DEVICE_FLAG_WAIT) != 0) {
g_topology_unlock();
G_RAID3_DEBUG(4, "%s: Waking up %p.", __func__,
@@ -3112,6 +3114,15 @@ g_raid3_destroy(struct g_raid3_softc *sc, int how)
}
}
+ g_topology_lock();
+ if (sc->sc_geom->softc == NULL) {
+ g_topology_unlock();
+ return (0);
+ }
+ sc->sc_geom->softc = NULL;
+ sc->sc_sync.ds_geom->softc = NULL;
+ g_topology_unlock();
+
sc->sc_flags |= G_RAID3_DEVICE_FLAG_DESTROY;
sc->sc_flags |= G_RAID3_DEVICE_FLAG_WAIT;
G_RAID3_DEBUG(4, "%s: Waking up %p.", __func__, sc);
OpenPOWER on IntegriCloud