mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-16 21:34:10 +00:00
Introduce new device flag G_MIRROR_DEVICE_FLAG_TASTING. It should
protect geom from destroying while it is tasting. PR: kern/154860 Reviewed by: pjd MFC after: 1 week
This commit is contained in:
parent
246d751711
commit
1ee0138d2f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235599
|
@ -1693,6 +1693,8 @@ g_mirror_can_destroy(struct g_mirror_softc *sc)
|
|||
gp = sc->sc_geom;
|
||||
if (gp->softc == NULL)
|
||||
return (1);
|
||||
if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_TASTING) != 0)
|
||||
return (0);
|
||||
LIST_FOREACH(cp, &gp->consumer, consumer) {
|
||||
if (g_mirror_is_busy(sc, cp))
|
||||
return (0);
|
||||
|
@ -3054,6 +3056,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
|||
G_MIRROR_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
|
||||
g_topology_unlock();
|
||||
sx_xlock(&sc->sc_lock);
|
||||
sc->sc_flags |= G_MIRROR_DEVICE_FLAG_TASTING;
|
||||
error = g_mirror_add_disk(sc, pp, &md);
|
||||
if (error != 0) {
|
||||
G_MIRROR_DEBUG(0, "Cannot add disk %s to %s (error=%d).",
|
||||
|
@ -3066,6 +3069,12 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
|||
}
|
||||
gp = NULL;
|
||||
}
|
||||
sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING;
|
||||
if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0) {
|
||||
g_mirror_destroy(sc, G_MIRROR_DESTROY_HARD);
|
||||
g_topology_lock();
|
||||
return (NULL);
|
||||
}
|
||||
sx_xunlock(&sc->sc_lock);
|
||||
g_topology_lock();
|
||||
return (gp);
|
||||
|
|
|
@ -157,6 +157,7 @@ struct g_mirror_event {
|
|||
#define G_MIRROR_DEVICE_FLAG_DESTROY 0x0100000000000000ULL
|
||||
#define G_MIRROR_DEVICE_FLAG_WAIT 0x0200000000000000ULL
|
||||
#define G_MIRROR_DEVICE_FLAG_DESTROYING 0x0400000000000000ULL
|
||||
#define G_MIRROR_DEVICE_FLAG_TASTING 0x0800000000000000ULL
|
||||
|
||||
#define G_MIRROR_DEVICE_STATE_STARTING 0
|
||||
#define G_MIRROR_DEVICE_STATE_RUNNING 1
|
||||
|
|
Loading…
Reference in a new issue