Module Name: src
Committed By: snj
Date: Mon Mar 9 08:56:02 UTC 2015
Modified Files:
src/sys/kern [netbsd-7]: init_main.c subr_autoconf.c
src/sys/sys [netbsd-7]: device.h
Log Message:
Pull up following revision(s) (requested by mrg in ticket #576):
sys/kern/init_main.c: revision 1.462
sys/kern/subr_autoconf.c: revision 1.234
sys/sys/device.h: revision 1.147
wait for config_mountroot threads to complete before we tell init it
can start up. this solves the problem where a console device needs
mountroot to complete attaching, and must create wsdisplay0 before
init tries to open /dev/console. fixes PR#49709.
XXX: pullup-7
To generate a diff of this commit:
cvs rdiff -u -r1.458.2.1 -r1.458.2.2 src/sys/kern/init_main.c
cvs rdiff -u -r1.231 -r1.231.2.1 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.144 -r1.144.4.1 src/sys/sys/device.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.458.2.1 src/sys/kern/init_main.c:1.458.2.2
--- src/sys/kern/init_main.c:1.458.2.1 Fri Aug 15 12:58:45 2014
+++ src/sys/kern/init_main.c Mon Mar 9 08:56:01 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.458.2.1 2014/08/15 12:58:45 martin Exp $ */
+/* $NetBSD: init_main.c,v 1.458.2.2 2015/03/09 08:56:01 snj Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.458.2.1 2014/08/15 12:58:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.458.2.2 2015/03/09 08:56:01 snj Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -712,6 +712,9 @@ main(void)
uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
panic("fork aiodoned");
+ /* Wait for final configure threads to complete. */
+ config_finalize_mountroot();
+
/*
* Okay, now we can let init(8) exec! It's off to userland!
*/
Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.231 src/sys/kern/subr_autoconf.c:1.231.2.1
--- src/sys/kern/subr_autoconf.c:1.231 Sun Aug 10 16:44:36 2014
+++ src/sys/kern/subr_autoconf.c Mon Mar 9 08:56:01 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.231 2014/08/10 16:44:36 tls Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.231.2.1 2015/03/09 08:56:01 snj Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.231 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.231.2.1 2015/03/09 08:56:01 snj Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -202,6 +202,8 @@ int interrupt_config_threads = 8;
struct deferred_config_head mountroot_config_queue =
TAILQ_HEAD_INITIALIZER(mountroot_config_queue);
int mountroot_config_threads = 2;
+static lwp_t **mountroot_config_lwpids;
+static size_t mountroot_config_lwpids_size;
static bool root_is_mounted = false;
static void config_process_deferred(struct deferred_config_head *, device_t);
@@ -481,10 +483,35 @@ config_create_mountrootthreads(void)
if (!root_is_mounted)
root_is_mounted = true;
+ mountroot_config_lwpids_size = sizeof(mountroot_config_lwpids) *
+ mountroot_config_threads;
+ mountroot_config_lwpids = kmem_alloc(mountroot_config_lwpids_size,
+ KM_NOSLEEP);
+ KASSERT(mountroot_config_lwpids);
for (i = 0; i < mountroot_config_threads; i++) {
- (void)kthread_create(PRI_NONE, 0, NULL,
- config_mountroot_thread, NULL, NULL, "configroot");
+ mountroot_config_lwpids[i] = 0;
+ (void)kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL,
+ config_mountroot_thread, NULL,
+ &mountroot_config_lwpids[i],
+ "configroot");
+ }
+}
+
+void
+config_finalize_mountroot(void)
+{
+ int i, error;
+
+ for (i = 0; i < mountroot_config_threads; i++) {
+ if (mountroot_config_lwpids[i] == 0)
+ continue;
+
+ error = kthread_join(mountroot_config_lwpids[i]);
+ if (error)
+ printf("%s: thread %x joined with error %d\n",
+ __func__, i, error);
}
+ kmem_free(mountroot_config_lwpids, mountroot_config_lwpids_size);
}
/*
Index: src/sys/sys/device.h
diff -u src/sys/sys/device.h:1.144 src/sys/sys/device.h:1.144.4.1
--- src/sys/sys/device.h:1.144 Sat Oct 12 16:49:01 2013
+++ src/sys/sys/device.h Mon Mar 9 08:56:02 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.144 2013/10/12 16:49:01 christos Exp $ */
+/* $NetBSD: device.h,v 1.144.4.1 2015/03/09 08:56:02 snj Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -476,6 +476,7 @@ void config_create_mountrootthreads(void
int config_finalize_register(device_t, int (*)(device_t));
void config_finalize(void);
+void config_finalize_mountroot(void);
void config_twiddle_init(void);
void config_twiddle_fn(void *);