Sun Jan 3 12:51:33 2021 UTC ()
Apply patch, requested by khorben in ticket #1177 (issue solved differently
in -current):

	sys/kern/init_main.c			(apply patch)

PR kern/55906: create the aiodone workqueue before running mountroothooks.


(martin)
diff -r1.504.2.1 -r1.504.2.2 src/sys/kern/init_main.c

cvs diff -r1.504.2.1 -r1.504.2.2 src/sys/kern/init_main.c (expand / switch to unified diff)

--- src/sys/kern/init_main.c 2020/11/14 15:36:11 1.504.2.1
+++ src/sys/kern/init_main.c 2021/01/03 12:51:33 1.504.2.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: init_main.c,v 1.504.2.1 2020/11/14 15:36:11 martin Exp $ */ 1/* $NetBSD: init_main.c,v 1.504.2.2 2021/01/03 12:51:33 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -87,27 +87,27 @@ @@ -87,27 +87,27 @@
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94 * SUCH DAMAGE. 94 * SUCH DAMAGE.
95 * 95 *
96 * @(#)init_main.c 8.16 (Berkeley) 5/14/95 96 * @(#)init_main.c 8.16 (Berkeley) 5/14/95
97 */ 97 */
98 98
99#include <sys/cdefs.h> 99#include <sys/cdefs.h>
100__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.504.2.1 2020/11/14 15:36:11 martin Exp $"); 100__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.504.2.2 2021/01/03 12:51:33 martin Exp $");
101 101
102#include "opt_ddb.h" 102#include "opt_ddb.h"
103#include "opt_inet.h" 103#include "opt_inet.h"
104#include "opt_ipsec.h" 104#include "opt_ipsec.h"
105#include "opt_modular.h" 105#include "opt_modular.h"
106#include "opt_ntp.h" 106#include "opt_ntp.h"
107#include "opt_pipe.h" 107#include "opt_pipe.h"
108#include "opt_syscall_debug.h" 108#include "opt_syscall_debug.h"
109#include "opt_sysv.h" 109#include "opt_sysv.h"
110#include "opt_fileassoc.h" 110#include "opt_fileassoc.h"
111#include "opt_ktrace.h" 111#include "opt_ktrace.h"
112#include "opt_pax.h" 112#include "opt_pax.h"
113#include "opt_compat_netbsd.h" 113#include "opt_compat_netbsd.h"
@@ -658,26 +658,31 @@ main(void) @@ -658,26 +658,31 @@ main(void)
658 * selected, since finalization may create the root device. 658 * selected, since finalization may create the root device.
659 */ 659 */
660 config_finalize(); 660 config_finalize();
661 661
662 sysctl_finalize(); 662 sysctl_finalize();
663 663
664 /* 664 /*
665 * Now that autoconfiguration has completed, we can determine 665 * Now that autoconfiguration has completed, we can determine
666 * the root and dump devices. 666 * the root and dump devices.
667 */ 667 */
668 cpu_rootconf(); 668 cpu_rootconf();
669 cpu_dumpconf(); 669 cpu_dumpconf();
670 670
 671 /* Create the aiodone daemon kernel thread. */
 672 if (workqueue_create(&uvm.aiodone_queue, "aiodoned",
 673 uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
 674 panic("fork aiodoned");
 675
671 /* Mount the root file system. */ 676 /* Mount the root file system. */
672 do { 677 do {
673 domountroothook(root_device); 678 domountroothook(root_device);
674 if ((error = vfs_mountroot())) { 679 if ((error = vfs_mountroot())) {
675 printf("cannot mount root, error = %d\n", error); 680 printf("cannot mount root, error = %d\n", error);
676 boothowto |= RB_ASKNAME; 681 boothowto |= RB_ASKNAME;
677 setroot(root_device, 682 setroot(root_device,
678 (rootdev != NODEV) ? DISKPART(rootdev) : 0); 683 (rootdev != NODEV) ? DISKPART(rootdev) : 0);
679 } 684 }
680 } while (error != 0); 685 } while (error != 0);
681 mountroothook_destroy(); 686 mountroothook_destroy();
682 687
683 configure3(); 688 configure3();
@@ -726,31 +731,26 @@ main(void) @@ -726,31 +731,26 @@ main(void)
726 } 731 }
727 732
728 /* Create the pageout daemon kernel thread. */ 733 /* Create the pageout daemon kernel thread. */
729 uvm_swap_init(); 734 uvm_swap_init();
730 if (kthread_create(PRI_PGDAEMON, KTHREAD_MPSAFE, NULL, uvm_pageout, 735 if (kthread_create(PRI_PGDAEMON, KTHREAD_MPSAFE, NULL, uvm_pageout,
731 NULL, NULL, "pgdaemon")) 736 NULL, NULL, "pgdaemon"))
732 panic("fork pagedaemon"); 737 panic("fork pagedaemon");
733 738
734 /* Create the filesystem syncer kernel thread. */ 739 /* Create the filesystem syncer kernel thread. */
735 if (kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL, sched_sync, 740 if (kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL, sched_sync,
736 NULL, NULL, "ioflush")) 741 NULL, NULL, "ioflush"))
737 panic("fork syncer"); 742 panic("fork syncer");
738 743
739 /* Create the aiodone daemon kernel thread. */ 
740 if (workqueue_create(&uvm.aiodone_queue, "aiodoned", 
741 uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE)) 
742 panic("fork aiodoned"); 
743 
744 /* Wait for final configure threads to complete. */ 744 /* Wait for final configure threads to complete. */
745 config_finalize_mountroot(); 745 config_finalize_mountroot();
746 746
747 /* 747 /*
748 * Okay, now we can let init(8) exec! It's off to userland! 748 * Okay, now we can let init(8) exec! It's off to userland!
749 */ 749 */
750 mutex_enter(proc_lock); 750 mutex_enter(proc_lock);
751 start_init_exec = 1; 751 start_init_exec = 1;
752 cv_broadcast(&lbolt); 752 cv_broadcast(&lbolt);
753 mutex_exit(proc_lock); 753 mutex_exit(proc_lock);
754 754
755 /* The scheduler is an infinite loop. */ 755 /* The scheduler is an infinite loop. */
756 uvm_scheduler(); 756 uvm_scheduler();