Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Move rootfs-related init from init_main() to vfs_mountro...



details:   https://anonhg.NetBSD.org/src/rev/a99f34e2c671
branches:  trunk
changeset: 749360:a99f34e2c671
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Nov 27 16:43:51 2009 +0000

description:
Move rootfs-related init from init_main() to vfs_mountroot().
Reduces code re-written in rump.

diffstat:

 sys/kern/init_main.c                |  29 ++---------------------------
 sys/kern/vfs_subr.c                 |  31 +++++++++++++++++++++++++++++--
 sys/rump/librump/rumpvfs/rump_vfs.c |  19 +++++++------------
 sys/rump/librump/rumpvfs/rumpfs.c   |   7 ++-----
 4 files changed, 40 insertions(+), 46 deletions(-)

diffs (188 lines):

diff -r 694ad9e6f0a9 -r a99f34e2c671 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Fri Nov 27 16:23:23 2009 +0000
+++ b/sys/kern/init_main.c      Fri Nov 27 16:43:51 2009 +0000
@@ -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
diff -r 694ad9e6f0a9 -r a99f34e2c671 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Fri Nov 27 16:23:23 2009 +0000
+++ b/sys/kern/vfs_subr.c       Fri Nov 27 16:43:51 2009 +0000
@@ -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);
 }
 
diff -r 694ad9e6f0a9 -r a99f34e2c671 sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Nov 27 16:23:23 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Nov 27 16:43:51 2009 +0000
@@ -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)
diff -r 694ad9e6f0a9 -r a99f34e2c671 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Fri Nov 27 16:23:23 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Fri Nov 27 16:43:51 2009 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index