Module Name:    src
Committed By:   hannken
Date:           Mon Jan  2 10:33:28 UTC 2017

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/share/man/man9: Makefile vnode.9 vnsubr.9
        src/sys/kern: vfs_cache.c vfs_mount.c vfs_subr.c vfs_vnode.c
        src/sys/miscfs/specfs: spec_vnops.c
        src/sys/sys: param.h vnode.h vnode_impl.h

Log Message:
Rename vget() to vcache_vget() and vcache_tryvget() respectively and
move the definitions to sys/vnode_impl.h.

No functional change intended.

Welcome to 7.99.54


To generate a diff of this commit:
cvs rdiff -u -r1.2089 -r1.2090 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.399 -r1.400 src/share/man/man9/Makefile
cvs rdiff -u -r1.73 -r1.74 src/share/man/man9/vnode.9
cvs rdiff -u -r1.43 -r1.44 src/share/man/man9/vnsubr.9
cvs rdiff -u -r1.110 -r1.111 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.452 -r1.453 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.65 -r1.66 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.167 -r1.168 src/sys/miscfs/specfs/spec_vnops.c
cvs rdiff -u -r1.520 -r1.521 src/sys/sys/param.h
cvs rdiff -u -r1.267 -r1.268 src/sys/sys/vnode.h
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/vnode_impl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2089 src/distrib/sets/lists/comp/mi:1.2090
--- src/distrib/sets/lists/comp/mi:1.2089	Mon Jan  2 10:28:35 2017
+++ src/distrib/sets/lists/comp/mi	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2089 2017/01/02 10:28:35 roy Exp $
+#	$NetBSD: mi,v 1.2090 2017/01/02 10:33:28 hannken Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp				comp-sys-root
@@ -11234,7 +11234,7 @@
 ./usr/share/man/cat9/vfs_write_suspend.0	comp-obsolete		obsolete
 ./usr/share/man/cat9/vfsops.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/vfssubr.0			comp-sys-catman		.cat
-./usr/share/man/cat9/vget.0			comp-sys-catman		.cat
+./usr/share/man/cat9/vget.0			comp-sys-catman		obsolete
 ./usr/share/man/cat9/vgone.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/vgonel.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/vhold.0			comp-sys-catman		.cat
@@ -18418,7 +18418,7 @@
 ./usr/share/man/html9/vfs_vnode_iterator_next.html	comp-sys-htmlman	html
 ./usr/share/man/html9/vfsops.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vfssubr.html		comp-sys-htmlman	html
-./usr/share/man/html9/vget.html			comp-sys-htmlman	html
+./usr/share/man/html9/vget.html			comp-sys-htmlman	obsolete
 ./usr/share/man/html9/vgone.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vgonel.html		comp-sys-htmlman	html
 ./usr/share/man/html9/vhold.html		comp-sys-htmlman	html
@@ -25842,7 +25842,7 @@
 ./usr/share/man/man9/vfs_write_suspend.9	comp-obsolete		obsolete
 ./usr/share/man/man9/vfsops.9			comp-sys-man		.man
 ./usr/share/man/man9/vfssubr.9			comp-sys-man		.man
-./usr/share/man/man9/vget.9			comp-sys-man		.man
+./usr/share/man/man9/vget.9			comp-sys-man		obsolete
 ./usr/share/man/man9/vgone.9			comp-sys-man		.man
 ./usr/share/man/man9/vgonel.9			comp-sys-man		.man
 ./usr/share/man/man9/vhold.9			comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.399 src/share/man/man9/Makefile:1.400
--- src/share/man/man9/Makefile:1.399	Thu Dec 22 11:46:48 2016
+++ src/share/man/man9/Makefile	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.399 2016/12/22 11:46:48 cherry Exp $
+#       $NetBSD: Makefile,v 1.400 2017/01/02 10:33:28 hannken Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -949,7 +949,6 @@ MLINKS+=vmem.9 vmem_alloc.9 \
 MLINKS+=vnode.9 vref.9 \
 	vnode.9 vrele.9 \
 	vnode.9 vrele_async.9 \
-	vnode.9 vget.9 \
 	vnode.9 vput.9 \
 	vnode.9 vhold.9 \
 	vnode.9 holdrele.9 \

Index: src/share/man/man9/vnode.9
diff -u src/share/man/man9/vnode.9:1.73 src/share/man/man9/vnode.9:1.74
--- src/share/man/man9/vnode.9:1.73	Wed Dec 14 15:48:54 2016
+++ src/share/man/man9/vnode.9	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnode.9,v 1.73 2016/12/14 15:48:54 hannken Exp $
+.\"     $NetBSD: vnode.9,v 1.74 2017/01/02 10:33:28 hannken Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 14, 2016
+.Dd January 2, 2017
 .Dt VNODE 9
 .Os
 .Sh NAME
@@ -35,7 +35,6 @@
 .Nm vref ,
 .Nm vrele ,
 .Nm vrele_async ,
-.Nm vget ,
 .Nm vput ,
 .Nm vhold ,
 .Nm holdrele ,
@@ -68,8 +67,6 @@
 .Fn vrele "struct vnode *vp"
 .Ft void
 .Fn vrele_async "struct vnode *vp"
-.Ft int
-.Fn vget "struct vnode *vp" "int lockflag" "int wait"
 .Ft void
 .Fn vput "struct vnode *vp"
 .Ft void
@@ -152,12 +149,10 @@ When a file system retrieves a vnode fro
 have any users, and another thread in the system may be simultaneously
 deciding to reclaim it.
 Thus, to retrieve a vnode from a cache, one must use
-.Fn vget ,
+.Fn vcache_get ,
 not
 .Fn vref ,
-to acquire the first reference, and be prepared for
-.Fn vget
-to fail if another thread is reclaiming the vnode.
+to acquire the first reference.
 .Pp
 The vnode has the following structure:
 .Bd -literal
@@ -349,10 +344,8 @@ See
 .Xr vnodeops 9
 for a description of vnode operations.
 .Pp
-When a valid vnode which is cached is used again, the user must call
-.Fn vget
-to increment the reference count.
-When a user wants a new vnode for another file,
+When a user wants a new vnode for another file or wants a valid vnode
+which is cached,
 .Fn vcache_get
 or
 .Fn vcache_new
@@ -540,60 +533,6 @@ are zero, the vnode is cached.
 .It Fn vrele_async "vp"
 Will asychronously release the vnode in different context than the caller,
 sometime after the call.
-.It Fn vget "vp" "lockflags" "wait"
-Reclaim vnode
-.Fa vp
-from the cache and increment its reference count.
-.Pp
-The vnode
-.Fa vp
-may be changing state: another thread may be initializing it from disk,
-or revoking it with
-.Xr revoke 2 ,
-or reclaiming it with
-.Xr VOP_RECLAIM 9 .
-In that case,
-.Fn vget
-will wait until the state has changed, if
-.Fa lockflags
-is
-.Li 0
-and
-.Fa wait
-is
-.Li true ;
-or will return
-.Er EBUSY
-if
-.Fa lockflags
-is
-.Dv LK_NOWAIT
-and
-.Fa wait
-is
-.Li false .
-.Pp
-(The extra argument enables the compiler to detect old code which
-additionally used
-.Fn vget
-to lock the vnode.)
-.Pp
-Returns
-.Bl -tag -offset abcd -width ENOENT -compact
-.It Er EBUSY
-if
-.Fa vp
-was changing state and
-.Fa wait
-is false.
-.It Er ENOENT
-if the system was reclaiming
-.Fa vp
-with
-.Xr VOP_RECLAIM 9 .
-.It Li 0
-on success.
-.El
 .It Fn vput "vp"
 Legacy convenience routine for unlocking and releasing
 .Fa vp .
@@ -603,11 +542,6 @@ Equivalent to:
 .No "vrele(" Ns Fa vp Ns Li ");"
 .Ed
 .Pp
-Note that this is
-.Em not
-an inverse of
-.Fn vget .
-The name appears so for hysterical raisins.
 New code should prefer using
 .Xr VOP_UNLOCK 9
 and

Index: src/share/man/man9/vnsubr.9
diff -u src/share/man/man9/vnsubr.9:1.43 src/share/man/man9/vnsubr.9:1.44
--- src/share/man/man9/vnsubr.9:1.43	Sat Jul 11 15:42:31 2015
+++ src/share/man/man9/vnsubr.9	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnsubr.9,v 1.43 2015/07/11 15:42:31 wiz Exp $
+.\"     $NetBSD: vnsubr.9,v 1.44 2017/01/02 10:33:28 hannken Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -146,9 +146,6 @@ appropriate error code is returned.
 .Pp
 .Fn vn_lock
 must not be called when the vnode's reference count is zero.
-Instead,
-.Xr vget 9
-should be used.
 .It Fn vn_markexec "vp"
 Common code to mark the vnode
 .Fa vp

Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.110 src/sys/kern/vfs_cache.c:1.111
--- src/sys/kern/vfs_cache.c:1.110	Thu Jul  7 06:55:43 2016
+++ src/sys/kern/vfs_cache.c	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.110 2016/07/07 06:55:43 msaitoh Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.110 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -71,7 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,
 #include <sys/sysctl.h>
 #include <sys/time.h>
 #include <sys/mount.h>
-#include <sys/vnode.h>
+#include <sys/vnode_impl.h>
 #include <sys/namei.h>
 #include <sys/errno.h>
 #include <sys/pool.h>
@@ -101,8 +101,8 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,
  * is for DELETE, or NOCACHE is set (rewrite), and the
  * name is located in the cache, it will be dropped.
  * The entry is dropped also when it was not possible to lock
- * the cached vnode, either because vget() failed or the generation
- * number has changed while waiting for the lock.
+ * the cached vnode, either because vcache_tryvget() failed or
+ * the generation number has changed while waiting for the lock.
  */
 
 /*
@@ -588,9 +588,9 @@ cache_lookup(struct vnode *dvp, const ch
 	mutex_exit(&cpup->cpu_lock);
 
 	/*
-	 * Unlocked except for the vnode interlock.  Call vget().
+	 * Unlocked except for the vnode interlock.  Call vcache_tryvget().
 	 */
-	error = vget(vp, LK_NOWAIT, false /* !wait */);
+	error = vcache_tryvget(vp);
 	if (error) {
 		KASSERT(error == EBUSY);
 		/*
@@ -669,9 +669,9 @@ cache_lookup_raw(struct vnode *dvp, cons
 	mutex_exit(&cpup->cpu_lock);
 
 	/*
-	 * Unlocked except for the vnode interlock.  Call vget().
+	 * Unlocked except for the vnode interlock.  Call vcache_tryvget().
 	 */
-	error = vget(vp, LK_NOWAIT, false /* !wait */);
+	error = vcache_tryvget(vp);
 	if (error) {
 		KASSERT(error == EBUSY);
 		/*
@@ -761,7 +761,7 @@ cache_revlookup(struct vnode *vp, struct
 			mutex_enter(dvp->v_interlock);
 			mutex_exit(&ncp->nc_lock);
 			mutex_exit(namecache_lock);
-			error = vget(dvp, LK_NOWAIT, false /* !wait */);
+			error = vcache_tryvget(dvp);
 			if (error) {
 				KASSERT(error == EBUSY);
 				if (bufp)

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.42 src/sys/kern/vfs_mount.c:1.43
--- src/sys/kern/vfs_mount.c:1.42	Wed Dec 14 15:46:57 2016
+++ src/sys/kern/vfs_mount.c	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.42 2016/12/14 15:46:57 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.42 2016/12/14 15:46:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -402,7 +402,7 @@ again:
 		TAILQ_INSERT_AFTER(&mp->mnt_vnodelist, vp, mvp, v_mntvnodes);
 		mvp->v_usecount = 1;
 		mutex_exit(&mntvnode_lock);
-		error = vget(vp, 0, true /* wait */);
+		error = vcache_vget(vp);
 		KASSERT(error == 0 || error == ENOENT);
 	} while (error != 0);
 
@@ -553,7 +553,7 @@ vflush(struct mount *mp, vnode_t *skipvp
 		if (vp != NULL) {
 			mutex_enter(vp->v_interlock);
 			mutex_exit(&mntvnode_lock);
-			error = vget(vp, 0, true /* wait */);
+			error = vcache_vget(vp);
 			if (error == ENOENT)
 				continue;
 			else if (error == 0)

Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.452 src/sys/kern/vfs_subr.c:1.453
--- src/sys/kern/vfs_subr.c:1.452	Wed Dec 14 15:48:55 2016
+++ src/sys/kern/vfs_subr.c	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.452 2016/12/14 15:48:55 hannken Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.453 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.452 2016/12/14 15:48:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.453 2017/01/02 10:33:28 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -736,7 +736,7 @@ lazy_sync_vnode(struct vnode *vp)
 	/* We are locking in the wrong direction. */
 	if (mutex_tryenter(vp->v_interlock)) {
 		mutex_exit(&syncer_data_lock);
-		if (vget(vp, LK_NOWAIT, false /* !wait */) == 0) {
+		if (vcache_tryvget(vp) == 0) {
 			if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT) == 0) {
 				synced = true;
 				(void) VOP_FSYNC(vp, curlwp->l_cred,

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.65 src/sys/kern/vfs_vnode.c:1.66
--- src/sys/kern/vfs_vnode.c:1.65	Tue Dec 27 11:59:36 2016
+++ src/sys/kern/vfs_vnode.c	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.66 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  *	starts in one of the following ways:
  *
  *	- Allocation, via vcache_get(9) or vcache_new(9).
- *	- Reclamation of inactive vnode, via vget(9).
+ *	- Reclamation of inactive vnode, via vcache_vget(9).
  *
  *	Recycle from a free list, via getnewvnode(9) -> getcleanvnode(9)
  *	was another, traditional way.  Currently, only the draining thread
@@ -156,7 +156,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.66 2017/01/02 10:33:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -482,7 +482,7 @@ vdrain_remove(vnode_t *vp)
 	vdrain_retry = true;
 	mutex_exit(&vdrain_lock);
 
-	if (vget(vp, 0, true /* wait */) == 0) {
+	if (vcache_vget(vp) == 0) {
 		if (!vrecycle(vp))
 			vrele(vp);
 	}
@@ -578,63 +578,6 @@ vdrain_thread(void *cookie)
 }
 
 /*
- * vget: get a particular vnode from the free list, increment its reference
- * count and return it.
- *
- * => Must be called with v_interlock held.
- *
- * If state is VS_RECLAIMING, the vnode may be eliminated in vcache_reclaim().
- * In that case, we cannot grab the vnode, so the process is awakened when
- * the transition is completed, and an error returned to indicate that the
- * vnode is no longer usable.
- *
- * If state is VS_LOADING or VS_BLOCKED, wait until the vnode enters a
- * stable state (VS_ACTIVE or VS_RECLAIMED).
- */
-int
-vget(vnode_t *vp, int flags, bool waitok)
-{
-
-	KASSERT(mutex_owned(vp->v_interlock));
-	KASSERT((flags & ~LK_NOWAIT) == 0);
-	KASSERT(waitok == ((flags & LK_NOWAIT) == 0));
-
-	/*
-	 * Before adding a reference, we must remove the vnode
-	 * from its freelist.
-	 */
-	if (vp->v_usecount == 0) {
-		vp->v_usecount = 1;
-	} else {
-		atomic_inc_uint(&vp->v_usecount);
-	}
-
-	/*
-	 * If the vnode is in the process of changing state we wait
-	 * for the change to complete and take care not to return
-	 * a clean vnode.
-	 */
-	if (! ISSET(flags, LK_NOWAIT))
-		VSTATE_WAIT_STABLE(vp);
-	if (VSTATE_GET(vp) == VS_RECLAIMED) {
-		vrelel(vp, 0);
-		return ENOENT;
-	} else if (VSTATE_GET(vp) != VS_ACTIVE) {
-		KASSERT(ISSET(flags, LK_NOWAIT));
-		vrelel(vp, 0);
-		return EBUSY;
-	}
-
-	/*
-	 * Ok, we got it in good shape.
-	 */
-	VSTATE_ASSERT(vp, VS_ACTIVE);
-	mutex_exit(vp->v_interlock);
-
-	return 0;
-}
-
-/*
  * vput: unlock and release the reference.
  */
 void
@@ -1124,6 +1067,97 @@ vcache_free(vnode_impl_t *node)
 }
 
 /*
+ * Try to get an initial reference on this cached vnode.
+ * Returns zero on success,  ENOENT if the vnode has been reclaimed and
+ * EBUSY if the vnode state is unstable.
+ *
+ * v_interlock locked on entry and unlocked on exit.
+ */
+int
+vcache_tryvget(vnode_t *vp)
+{
+
+	KASSERT(mutex_owned(vp->v_interlock));
+
+	/*
+	 * Before adding a reference, we must remove the vnode
+	 * from its freelist.
+	 */
+	if (vp->v_usecount == 0) {
+		vp->v_usecount = 1;
+	} else {
+		atomic_inc_uint(&vp->v_usecount);
+	}
+
+	/*
+	 * If the vnode is in the process of changing state we wait
+	 * for the change to complete and take care not to return
+	 * a clean vnode.
+	 */
+	if (VSTATE_GET(vp) == VS_RECLAIMED) {
+		vrelel(vp, 0);
+		return ENOENT;
+	} else if (VSTATE_GET(vp) != VS_ACTIVE) {
+		vrelel(vp, 0);
+		return EBUSY;
+	}
+
+	/*
+	 * Ok, we got it in good shape.
+	 */
+	VSTATE_ASSERT(vp, VS_ACTIVE);
+	mutex_exit(vp->v_interlock);
+
+	return 0;
+}
+
+/*
+ * Try to get an initial reference on this cached vnode.
+ * Returns zero on success and  ENOENT if the vnode has been reclaimed.
+ * Will wait for the vnode state to be stable.
+ *
+ * v_interlock locked on entry and unlocked on exit.
+ */
+int
+vcache_vget(vnode_t *vp)
+{
+
+	KASSERT(mutex_owned(vp->v_interlock));
+
+	/*
+	 * Before adding a reference, we must remove the vnode
+	 * from its freelist.
+	 */
+	if (vp->v_usecount == 0) {
+		vp->v_usecount = 1;
+	} else {
+		atomic_inc_uint(&vp->v_usecount);
+	}
+
+	/*
+	 * If the vnode is in the process of changing state we wait
+	 * for the change to complete and take care not to return
+	 * a clean vnode.
+	 */
+	VSTATE_WAIT_STABLE(vp);
+	if (VSTATE_GET(vp) == VS_RECLAIMED) {
+		vrelel(vp, 0);
+		return ENOENT;
+	} else if (VSTATE_GET(vp) != VS_ACTIVE) {
+		vrelel(vp, 0);
+		return EBUSY;
+	}
+
+	/*
+	 * Ok, we got it in good shape.
+	 */
+	VSTATE_ASSERT(vp, VS_ACTIVE);
+	mutex_exit(vp->v_interlock);
+
+	return 0;
+}
+
+/*
  * Get a vnode / fs node pair by key and return it referenced through vpp.
  */
 int
@@ -1167,7 +1201,7 @@ again:
 		vp = VIMPL_TO_VNODE(node);
 		mutex_enter(vp->v_interlock);
 		mutex_exit(&vcache.lock);
-		error = vget(vp, 0, true /* wait */);
+		error = vcache_vget(vp);
 		if (error == ENOENT)
 			goto again;
 		if (error == 0)
@@ -1282,7 +1316,7 @@ vcache_new(struct mount *mp, struct vnod
 		ovp = VIMPL_TO_VNODE(old_node);
 		mutex_enter(ovp->v_interlock);
 		mutex_exit(&vcache.lock);
-		error = vget(ovp, 0, true /* wait */);
+		error = vcache_vget(ovp);
 		KASSERT(error == ENOENT);
 		mutex_enter(&vcache.lock);
 	}

Index: src/sys/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.167 src/sys/miscfs/specfs/spec_vnops.c:1.168
--- src/sys/miscfs/specfs/spec_vnops.c:1.167	Fri Dec  9 19:13:47 2016
+++ src/sys/miscfs/specfs/spec_vnops.c	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.167 2016/12/09 19:13:47 nat Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.167 2016/12/09 19:13:47 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: spec_vnops.c
 #include <sys/buf.h>
 #include <sys/mount.h>
 #include <sys/namei.h>
-#include <sys/vnode.h>
+#include <sys/vnode_impl.h>
 #include <sys/stat.h>
 #include <sys/errno.h>
 #include <sys/ioctl.h>
@@ -310,7 +310,7 @@ spec_node_lookup_by_dev(enum vtype type,
 		mutex_enter(vp->v_interlock);
 	}
 	mutex_exit(&device_lock);
-	error = vget(vp, 0, true /* wait */);
+	error = vcache_vget(vp);
 	if (error != 0)
 		return error;
 	*vpp = vp;
@@ -345,7 +345,7 @@ spec_node_lookup_by_mount(struct mount *
 	}
 	mutex_enter(vq->v_interlock);
 	mutex_exit(&device_lock);
-	error = vget(vq, 0, true /* wait */);
+	error = vcache_vget(vq);
 	if (error != 0)
 		return error;
 	*vpp = vq;

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.520 src/sys/sys/param.h:1.521
--- src/sys/sys/param.h:1.520	Wed Dec 28 07:34:33 2016
+++ src/sys/sys/param.h	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.520 2016/12/28 07:34:33 ozaki-r Exp $	*/
+/*	$NetBSD: param.h,v 1.521 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	799005300	/* NetBSD 7.99.53 */
+#define	__NetBSD_Version__	799005400	/* NetBSD 7.99.54 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

Index: src/sys/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.267 src/sys/sys/vnode.h:1.268
--- src/sys/sys/vnode.h:1.267	Wed Dec 14 15:48:55 2016
+++ src/sys/sys/vnode.h	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.267 2016/12/14 15:48:55 hannken Exp $	*/
+/*	$NetBSD: vnode.h,v 1.268 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -518,7 +518,6 @@ void	vdevgone(int, int, int, enum vtype)
 int	vfinddev(dev_t, enum vtype, struct vnode **);
 int	vflush(struct mount *, struct vnode *, int);
 int	vflushbuf(struct vnode *, int);
-int 	vget(struct vnode *, int, bool);
 void 	vgone(struct vnode *);
 int	vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
 void	vprint(const char *, struct vnode *);

Index: src/sys/sys/vnode_impl.h
diff -u src/sys/sys/vnode_impl.h:1.4 src/sys/sys/vnode_impl.h:1.5
--- src/sys/sys/vnode_impl.h:1.4	Wed Dec 14 15:48:55 2016
+++ src/sys/sys/vnode_impl.h	Mon Jan  2 10:33:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode_impl.h,v 1.4 2016/12/14 15:48:55 hannken Exp $	*/
+/*	$NetBSD: vnode_impl.h,v 1.5 2017/01/02 10:33:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -71,6 +71,8 @@ vnode_t *
 	vnalloc_marker(struct mount *);
 void	vnfree_marker(vnode_t *);
 bool	vnis_marker(vnode_t *);
+int	vcache_vget(vnode_t *);
+int	vcache_tryvget(vnode_t *);
 int	vfs_drainvnodes(void);
 
 #endif /* !_SYS_VNODE_IMPL_H_ */

Reply via email to