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
This commit is contained in:
snj 2015-03-09 08:56:01 +00:00
parent e25bba3ffc
commit d9ef26b155
3 changed files with 38 additions and 7 deletions

View File

@ -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!
*/

View File

@ -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,12 +483,37 @@ 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);
}
/*
* Announce device attach/detach to userland listeners.
*/

View File

@ -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 *);