Module Name: src Committed By: pooka Date: Fri Nov 27 16:43:51 UTC 2009
Modified Files: src/sys/kern: init_main.c vfs_subr.c src/sys/rump/librump/rumpvfs: rump_vfs.c rumpfs.c Log Message: Move rootfs-related init from init_main() to vfs_mountroot(). Reduces code re-written in rump. To generate a diff of this commit: cvs rdiff -u -r1.410 -r1.411 src/sys/kern/init_main.c cvs rdiff -u -r1.390 -r1.391 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.36 -r1.37 src/sys/rump/librump/rumpvfs/rump_vfs.c cvs rdiff -u -r1.30 -r1.31 src/sys/rump/librump/rumpvfs/rumpfs.c 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.410 src/sys/kern/init_main.c:1.411 --- src/sys/kern/init_main.c:1.410 Sun Nov 15 02:37:13 2009 +++ src/sys/kern/init_main.c Fri Nov 27 16:43:51 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.410 2009/11/15 02:37:13 elad Exp $ */ +/* $NetBSD: init_main.c,v 1.411 2009/11/27 16:43:51 pooka 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.410 2009/11/15 02:37:13 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.411 2009/11/27 16:43:51 pooka Exp $"); #include "opt_ddb.h" #include "opt_ipsec.h" @@ -253,7 +253,6 @@ extern struct proc proc0; extern struct lwp lwp0; -extern struct cwdinfo cwdi0; extern time_t rootfstime; #ifndef curlwp @@ -632,30 +631,6 @@ */ inittodr(rootfstime); - CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS; - CIRCLEQ_FIRST(&mountlist)->mnt_op->vfs_refcount++; - - /* - * Get the vnode for '/'. Set filedesc0.fd_fd.fd_cdir to - * reference it. - */ - error = VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode); - if (error) - panic("cannot find root vnode, error=%d", error); - cwdi0.cwdi_cdir = rootvnode; - VREF(cwdi0.cwdi_cdir); - VOP_UNLOCK(rootvnode, 0); - cwdi0.cwdi_rdir = NULL; - - /* - * Now that root is mounted, we can fixup initproc's CWD - * info. All other processes are kthreads, which merely - * share proc0's CWD info. - */ - initproc->p_cwdi->cwdi_cdir = rootvnode; - VREF(initproc->p_cwdi->cwdi_cdir); - initproc->p_cwdi->cwdi_rdir = NULL; - /* * Now can look at time, having had a chance to verify the time * from the file system. Reset l->l_rtime as it may have been Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.390 src/sys/kern/vfs_subr.c:1.391 --- src/sys/kern/vfs_subr.c:1.390 Thu Nov 26 20:52:19 2009 +++ src/sys/kern/vfs_subr.c Fri Nov 27 16:43:51 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.390 2009/11/26 20:52:19 pooka Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.391 2009/11/27 16:43:51 pooka Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.390 2009/11/26 20:52:19 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.391 2009/11/27 16:43:51 pooka Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -2567,6 +2567,33 @@ VOP_CLOSE(rootvp, FREAD, FSCRED); vrele(rootvp); } + if (error == 0) { + extern struct cwdinfo cwdi0; + + CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS; + CIRCLEQ_FIRST(&mountlist)->mnt_op->vfs_refcount++; + + /* + * Get the vnode for '/'. Set cwdi0.cwdi_cdir to + * reference it. + */ + error = VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode); + if (error) + panic("cannot find root vnode, error=%d", error); + cwdi0.cwdi_cdir = rootvnode; + VREF(cwdi0.cwdi_cdir); + VOP_UNLOCK(rootvnode, 0); + cwdi0.cwdi_rdir = NULL; + + /* + * Now that root is mounted, we can fixup initproc's CWD + * info. All other processes are kthreads, which merely + * share proc0's CWD info. + */ + initproc->p_cwdi->cwdi_cdir = rootvnode; + VREF(initproc->p_cwdi->cwdi_cdir); + initproc->p_cwdi->cwdi_rdir = NULL; + } return (error); } Index: src/sys/rump/librump/rumpvfs/rump_vfs.c diff -u src/sys/rump/librump/rumpvfs/rump_vfs.c:1.36 src/sys/rump/librump/rumpvfs/rump_vfs.c:1.37 --- src/sys/rump/librump/rumpvfs/rump_vfs.c:1.36 Thu Nov 26 21:04:42 2009 +++ src/sys/rump/librump/rumpvfs/rump_vfs.c Fri Nov 27 16:43:51 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs.c,v 1.36 2009/11/26 21:04:42 pooka Exp $ */ +/* $NetBSD: rump_vfs.c,v 1.37 2009/11/27 16:43:51 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.36 2009/11/26 21:04:42 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.37 2009/11/27 16:43:51 pooka Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -113,6 +113,11 @@ rootfstype = ROOT_FSTYPE_ANY; root_device = RUMP_VFSROOTDEV; + /* bootstrap cwdi (rest done in vfs_mountroot() */ + rw_init(&cwdi0.cwdi_lock); + proc0.p_cwdi = &cwdi0; + proc0.p_cwdi = cwdinit(); + /* * XXX: make sure rumpfs is attached. The opposite can * happen e.g. on Linux where the dynlinker doesn't work @@ -122,20 +127,10 @@ vfs_attach(&rumpfs_vfsops); vfs_mountroot(); - VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode); rump_proc_vfs_init = pvfs_init; rump_proc_vfs_release = pvfs_rele; - /* bootstrap cwdi */ - rw_init(&cwdi0.cwdi_lock); - cwdi0.cwdi_cdir = rootvnode; - vref(cwdi0.cwdi_cdir); - proc0.p_cwdi = &cwdi0; - proc0.p_cwdi = cwdinit(); - - VOP_UNLOCK(rootvnode, 0); - if (rump_threads) { if ((rv = kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL, sched_sync, NULL, NULL, "ioflush")) != 0) Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.30 src/sys/rump/librump/rumpvfs/rumpfs.c:1.31 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.30 Thu Nov 26 20:58:51 2009 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Fri Nov 27 16:43:51 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.30 2009/11/26 20:58:51 pooka Exp $ */ +/* $NetBSD: rumpfs.c,v 1.31 2009/11/27 16:43:51 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.30 2009/11/26 20:58:51 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.31 2009/11/27 16:43:51 pooka Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -875,9 +875,6 @@ mp->mnt_data = rfsmp; VOP_UNLOCK(rfsmp->rfsmp_rvp, 0); - mp->mnt_flag |= MNT_ROOTFS; - rumpfs_vfsops.vfs_refcount++; - mutex_enter(&mountlist_lock); CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); mutex_exit(&mountlist_lock);