Index: g_raid3.c =================================================================== RCS file: /private/FreeBSD/src/sys/geom/raid3/g_raid3.c,v retrieving revision 1.18 diff -u -p -r1.18 g_raid3.c --- g_raid3.c 28 Sep 2004 07:33:37 -0000 1.18 +++ g_raid3.c 14 Oct 2004 10:49:57 -0000 @@ -2113,6 +2113,7 @@ g_raid3_update_device(struct g_raid3_sof G_RAID3_BUMP_ON_FIRST_WRITE; } } + wakeup(&g_raid3_class); break; } case G_RAID3_DEVICE_STATE_DEGRADED: @@ -2905,4 +2906,53 @@ g_raid3_dumpconf(struct sbuf *sb, const } } +static int +g_raid3_can_go(void) +{ + struct g_raid3_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_raid3_class.geom, geom) { + sc = gp->softc; + if (sc == NULL) { + can_go = 0; + break; + } + 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_raid3_rootwait(void) +{ + + /* + * HACK: Wait for GEOM, because g_raid3_rootwait() can be called, + * HACK: before we get providers for tasting. + */ + tsleep(&g_raid3_class, PRIBIO, "r3root", hz * 3); + /* + * Wait for raid3 devices in degraded state. + */ + for (;;) { + if (g_raid3_can_go()) + break; + tsleep(&g_raid3_class, PRIBIO, "r3root", hz); + } +} + +SYSINIT(g_raid3_root, SI_SUB_RAID, SI_ORDER_FIRST, g_raid3_rootwait, NULL) + DECLARE_GEOM_CLASS(g_raid3_class, g_raid3);