Index: g_mirror.c =================================================================== RCS file: /private/FreeBSD/src/sys/geom/mirror/g_mirror.c,v retrieving revision 1.19.2.3 diff -u -p -r1.19.2.3 g_mirror.c --- g_mirror.c 28 Sep 2004 18:23:14 -0000 1.19.2.3 +++ g_mirror.c 5 Oct 2004 13:48:27 -0000 @@ -1911,6 +1911,7 @@ g_mirror_update_device(struct g_mirror_s G_MIRROR_BUMP_ON_FIRST_WRITE; } } + wakeup(&g_mirror_class); break; } case G_MIRROR_DEVICE_STATE_RUNNING: @@ -2689,4 +2690,44 @@ g_mirror_dumpconf(struct sbuf *sb, const } } +static int +g_mirror_can_go(void) +{ + struct g_mirror_softc *sc; + struct g_geom *gp; + struct g_provider *pp; + int can_go; + + DROP_GIANT(); + can_go = 1; + g_topology_lock(); + LIST_FOREACH(gp, &g_mirror_class.geom, geom) { + sc = gp->softc; + pp = sc->sc_provider; + if (pp == NULL || pp->error != 0) { + can_go = 0; + break; + } + } + g_topology_unlock(); + PICKUP_GIANT(); + return (can_go); +} + +static void +g_mirror_rootwait(void) +{ + + /* + * Wait for mirrors in degraded state. + */ + for (;;) { + if (g_mirror_can_go()) + break; + tsleep(&g_mirror_class, PRIBIO, "mroot", hz); + } +} + +SYSINIT(g_mirror_root, SI_SUB_RAID, SI_ORDER_FIRST, g_mirror_rootwait, NULL) + DECLARE_GEOM_CLASS(g_mirror_class, g_mirror);