Source-Changes-HG archive

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

[src/trunk]: src/sys/kern vfs_mountroot(): don't needlessly grab a second ref...



details:   https://anonhg.NetBSD.org/src/rev/c1b07e9e8afb
branches:  trunk
changeset: 930637:c1b07e9e8afb
user:      ad <ad%NetBSD.org@localhost>
date:      Fri Apr 10 22:34:36 2020 +0000

description:
vfs_mountroot(): don't needlessly grab a second reference to the root vnode
(the kernel never chdirs) nor a lock on it.

diffstat:

 sys/kern/vfs_mount.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (36 lines):

diff -r c8121810c434 -r c1b07e9e8afb sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Fri Apr 10 21:56:41 2020 +0000
+++ b/sys/kern/vfs_mount.c      Fri Apr 10 22:34:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.75 2020/02/23 22:14:03 ad Exp $        */
+/*     $NetBSD: vfs_mount.c,v 1.76 2020/04/10 22:34:36 ad Exp $        */
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.75 2020/02/23 22:14:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.76 2020/04/10 22:34:36 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1245,14 +1245,13 @@
 
                /*
                 * Get the vnode for '/'.  Set cwdi0.cwdi_cdir to
-                * reference it.
+                * reference it, and donate it the reference grabbed
+                * with VFS_ROOT().
                 */
-               error = VFS_ROOT(mp, LK_SHARED, &rootvnode);
+               error = VFS_ROOT(mp, LK_NONE, &rootvnode);
                if (error)
                        panic("cannot find root vnode, error=%d", error);
                cwdi0.cwdi_cdir = rootvnode;
-               vref(cwdi0.cwdi_cdir);
-               VOP_UNLOCK(rootvnode);
                cwdi0.cwdi_rdir = NULL;
 
                /*



Home | Main Index | Thread Index | Old Index