summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2012-01-16 16:29:50 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2012-01-16 16:29:50 +0000
commit197679ac3ac6257cd4f18f9f5d3c4a17ce63411b (patch)
treed8178cc6802618734090e2fdca7e197378d724c1
parent07e2fb24d0cfb10f66e48857d6f0f328875c2e2f (diff)
Ensure that all disk attach callbacks have completed before attempting
to locate the root via DUID. ok krw@
-rw-r--r--sys/kern/subr_disk.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 10d181c6fa2..acf29011f81 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.139 2012/01/13 14:39:31 jsing Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.140 2012/01/16 16:29:49 jsing Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -1161,7 +1161,7 @@ parsedisk(char *str, int len, int defpart, dev_t *devp)
void
setroot(struct device *bootdv, int part, int exitflags)
{
- int majdev, unit, len, s;
+ int majdev, unit, len, s, slept = 0;
struct swdevt *swp;
struct device *rootdv, *dv;
dev_t nrootdev, nswapdev = NODEV, temp = NODEV;
@@ -1173,6 +1173,20 @@ setroot(struct device *bootdv, int part, int exitflags)
extern char *nfsbootdevname;
#endif
+ /* Ensure that all disk attach callbacks have completed. */
+ do {
+ TAILQ_FOREACH(dk, &disklist, dk_link) {
+ if ((dk->dk_flags & DKF_OPENED) == 0) {
+ tsleep(dk, 0, "dkopen", hz);
+ slept++;
+ break;
+ }
+ }
+ } while (dk != NULL && slept < 5);
+
+ if (slept == 5)
+ printf("not all disklabels read successfully\n");
+
/* Locate DUID for boot disk if not already provided. */
bzero(duid, sizeof(duid));
if (bcmp(bootduid, duid, sizeof(bootduid)) == 0) {