diff options
author | pjd <pjd@FreeBSD.org> | 2006-04-28 11:47:28 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-04-28 11:47:28 +0000 |
commit | f430b234fbeaddfaa674f222692ee7d4155fc97f (patch) | |
tree | 7f399ba0d502d9fa9fc70346f008218e02f04bfc /sys | |
parent | 64fbab4133abf6d215ae98b9f0a8d40b57fb5e58 (diff) | |
download | FreeBSD-src-f430b234fbeaddfaa674f222692ee7d4155fc97f.zip FreeBSD-src-f430b234fbeaddfaa674f222692ee7d4155fc97f.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')
-rw-r--r-- | sys/geom/mirror/g_mirror.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 31ac2dd..80cac30 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -539,13 +539,11 @@ g_mirror_destroy_device(struct g_mirror_softc *sc) } } callout_drain(&sc->sc_callout); - gp->softc = NULL; g_topology_lock(); LIST_FOREACH_SAFE(cp, &sc->sc_sync.ds_geom->consumer, consumer, tmpcp) { g_mirror_disconnect_consumer(sc, cp); } - sc->sc_sync.ds_geom->softc = NULL; g_wither_geom(sc->sc_sync.ds_geom, ENXIO); G_MIRROR_DEBUG(0, "Device %s destroyed.", gp->name); g_wither_geom(gp, ENXIO); @@ -1660,6 +1658,8 @@ g_mirror_can_destroy(struct g_mirror_softc *sc) g_topology_assert(); gp = sc->sc_geom; + if (gp->softc == NULL) + return (1); LIST_FOREACH(cp, &gp->consumer, consumer) { if (g_mirror_is_busy(sc, cp)) return (0); @@ -1689,6 +1689,8 @@ g_mirror_try_destroy(struct g_mirror_softc *sc) g_topology_unlock(); return (0); } + sc->sc_geom->softc = NULL; + sc->sc_sync.ds_geom->softc = NULL; if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_WAIT) != 0) { g_topology_unlock(); G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, @@ -2886,6 +2888,15 @@ g_mirror_destroy(struct g_mirror_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_MIRROR_DEVICE_FLAG_DESTROY; sc->sc_flags |= G_MIRROR_DEVICE_FLAG_WAIT; G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, sc); |