Module Name:    src
Committed By:   hannken
Date:           Tue Oct 29 09:53:51 UTC 2013

Modified Files:
        src/external/cddl/osnet/sys/sys: vnode.h
        src/share/man/man9: vnode.9
        src/sys/kern: uipc_usrreq.c vfs_cache.c vfs_mount.c vfs_vnode.c
        src/sys/miscfs/procfs: procfs_subr.c
        src/sys/sys: param.h vnode.h
        src/sys/ufs/ext2fs: ext2fs_vfsops.c
        src/sys/ufs/ffs: ffs_vfsops.c
        src/sys/ufs/lfs: lfs_segment.c lfs_syscalls.c

Log Message:
Vnode API cleanup pass 1.

- Make these defines and functions private to vfs_vnode.c:

  VC_MASK, VC_LOCK, DOCLOSE, VI_IANCTREDO and VI_INACTNOW
  vclean() and vrelel()

- Remove the long time unused lwp argument from vrecycle().

- Remove vtryget(), it is responsible for ugly hacks and doesn't
  look that effective.

Presented on tech-kern.

Welcome to 6.99.25


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/cddl/osnet/sys/sys/vnode.h
cvs rdiff -u -r1.56 -r1.57 src/share/man/man9/vnode.9
cvs rdiff -u -r1.147 -r1.148 src/sys/kern/uipc_usrreq.c
cvs rdiff -u -r1.91 -r1.92 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/vfs_mount.c src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.102 -r1.103 src/sys/miscfs/procfs/procfs_subr.c
cvs rdiff -u -r1.433 -r1.434 src/sys/sys/param.h
cvs rdiff -u -r1.238 -r1.239 src/sys/sys/vnode.h
cvs rdiff -u -r1.173 -r1.174 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.289 -r1.290 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.232 -r1.233 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/lfs/lfs_syscalls.c

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

Modified files:

Index: src/external/cddl/osnet/sys/sys/vnode.h
diff -u src/external/cddl/osnet/sys/sys/vnode.h:1.11 src/external/cddl/osnet/sys/sys/vnode.h:1.12
--- src/external/cddl/osnet/sys/sys/vnode.h:1.11	Mon Sep 23 20:44:24 2013
+++ src/external/cddl/osnet/sys/sys/vnode.h	Tue Oct 29 09:53:51 2013
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: vnode.h,v 1.11 2013/09/23 20:44:24 christos Exp $	*/
+/*	$NetBSD: vnode.h,v 1.12 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -686,7 +686,6 @@ vn_remove(char *fnamep, enum uio_seg seg
 
 #define VN_RELE_ASYNC(vp, taskq) 	vrele_async((vp))
 #define vn_exists(a) 	do { } while(0)
-#define vn_reinit(a) 	vclean((a), 0)
 
 /*
  * Flags for VOP_LOOKUP

Index: src/share/man/man9/vnode.9
diff -u src/share/man/man9/vnode.9:1.56 src/share/man/man9/vnode.9:1.57
--- src/share/man/man9/vnode.9:1.56	Wed Feb  8 09:32:47 2012
+++ src/share/man/man9/vnode.9	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnode.9,v 1.56 2012/02/08 09:32:47 wiz Exp $
+.\"     $NetBSD: vnode.9,v 1.57 2013/10/29 09:53:51 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 February 8, 2012
+.Dd October 29, 2013
 .Dt VNODE 9
 .Os
 .Sh NAME
@@ -79,7 +79,7 @@
 .Ft void
 .Fn ungetnewvnode "struct vnode *vp"
 .Ft int
-.Fn vrecycle "struct vnode *vp" "struct simplelock *inter_lkp" "struct lwp *l"
+.Fn vrecycle "struct vnode *vp" "struct simplelock *inter_lkp"
 .Ft void
 .Fn vgone "struct vnode *vp"
 .Ft void
@@ -617,7 +617,7 @@ This function is needed for
 .Xr VFS_VGET 9
 which may need to push back a vnode in case of a locking race
 condition.
-.It Fn vrecycle "vp" "inter_lkp" "l"
+.It Fn vrecycle "vp" "inter_lkp"
 Recycle the unused vnode
 .Fa vp
 to the front of the freelist.

Index: src/sys/kern/uipc_usrreq.c
diff -u src/sys/kern/uipc_usrreq.c:1.147 src/sys/kern/uipc_usrreq.c:1.148
--- src/sys/kern/uipc_usrreq.c:1.147	Fri Oct 25 19:55:22 2013
+++ src/sys/kern/uipc_usrreq.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_usrreq.c,v 1.147 2013/10/25 19:55:22 martin Exp $	*/
+/*	$NetBSD: uipc_usrreq.c,v 1.148 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.147 2013/10/25 19:55:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.148 2013/10/29 09:53:51 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -851,7 +851,8 @@ unp_detach(struct unpcb *unp)
 		/* XXXAD racy */
 		mutex_enter(vp->v_interlock);
 		vp->v_socket = NULL;
-		vrelel(vp, 0);
+		mutex_exit(vp->v_interlock);
+		vrele(vp);
 		solock(so);
 		unp->unp_vnode = NULL;
 	}

Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.91 src/sys/kern/vfs_cache.c:1.92
--- src/sys/kern/vfs_cache.c:1.91	Mon Nov  5 17:27:39 2012
+++ src/sys/kern/vfs_cache.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.91 2012/11/05 17:27:39 dholland Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.92 2013/10/29 09:53:51 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.91 2012/11/05 17:27:39 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.92 2013/10/29 09:53:51 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_revcache.h"
@@ -442,24 +442,19 @@ cache_lookup(struct vnode *dvp, const ch
 	}
 
 	vp = ncp->nc_vp;
-	if (vtryget(vp)) {
-		mutex_exit(&ncp->nc_lock);
-		mutex_exit(&cpup->cpu_lock);
-	} else {
-		mutex_enter(vp->v_interlock);
-		mutex_exit(&ncp->nc_lock);
-		mutex_exit(&cpup->cpu_lock);
-		error = vget(vp, LK_NOWAIT);
-		if (error) {
-			KASSERT(error == EBUSY);
-			/*
-			 * This vnode is being cleaned out.
-			 * XXX badhits?
-			 */
-			COUNT(cpup->cpu_stats, ncs_falsehits);
-			/* found nothing */
-			return 0;
-		}
+	mutex_enter(vp->v_interlock);
+	mutex_exit(&ncp->nc_lock);
+	mutex_exit(&cpup->cpu_lock);
+	error = vget(vp, LK_NOWAIT);
+	if (error) {
+		KASSERT(error == EBUSY);
+		/*
+		 * This vnode is being cleaned out.
+		 * XXX badhits?
+		 */
+		COUNT(cpup->cpu_stats, ncs_falsehits);
+		/* found nothing */
+		return 0;
 	}
 
 #ifdef DEBUG
@@ -552,24 +547,19 @@ cache_lookup_raw(struct vnode *dvp, cons
 		/* found negative entry; vn is already null from above */
 		return 1;
 	}
-	if (vtryget(vp)) {
-		mutex_exit(&ncp->nc_lock);
-		mutex_exit(&cpup->cpu_lock);
-	} else {
-		mutex_enter(vp->v_interlock);
-		mutex_exit(&ncp->nc_lock);
-		mutex_exit(&cpup->cpu_lock);
-		error = vget(vp, LK_NOWAIT);
-		if (error) {
-			KASSERT(error == EBUSY);
-			/*
-			 * This vnode is being cleaned out.
-			 * XXX badhits?
-			 */
-			COUNT(cpup->cpu_stats, ncs_falsehits);
-			/* found nothing */
-			return 0;
-		}
+	mutex_enter(vp->v_interlock);
+	mutex_exit(&ncp->nc_lock);
+	mutex_exit(&cpup->cpu_lock);
+	error = vget(vp, LK_NOWAIT);
+	if (error) {
+		KASSERT(error == EBUSY);
+		/*
+		 * This vnode is being cleaned out.
+		 * XXX badhits?
+		 */
+		COUNT(cpup->cpu_stats, ncs_falsehits);
+		/* found nothing */
+		return 0;
 	}
 
 	/* Unlocked, but only for stats. */
@@ -639,21 +629,16 @@ cache_revlookup(struct vnode *vp, struct
 				*bpp = bp;
 			}
 
-			if (vtryget(dvp)) {
-				mutex_exit(&ncp->nc_lock); 
-				mutex_exit(namecache_lock);
-			} else {
-				mutex_enter(dvp->v_interlock);
-				mutex_exit(&ncp->nc_lock); 
-				mutex_exit(namecache_lock);
-				error = vget(dvp, LK_NOWAIT);
-				if (error) {
-					KASSERT(error == EBUSY);
-					if (bufp)
-						(*bpp) += nlen;
-					*dvpp = NULL;
-					return -1;
-				}
+			mutex_enter(dvp->v_interlock);
+			mutex_exit(&ncp->nc_lock); 
+			mutex_exit(namecache_lock);
+			error = vget(dvp, LK_NOWAIT);
+			if (error) {
+				KASSERT(error == EBUSY);
+				if (bufp)
+					(*bpp) += nlen;
+				*dvpp = NULL;
+				return -1;
 			}
 			*dvpp = dvp;
 			return (0);

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.22 src/sys/kern/vfs_mount.c:1.23
--- src/sys/kern/vfs_mount.c:1.22	Fri Oct 25 20:37:17 2013
+++ src/sys/kern/vfs_mount.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.22 2013/10/25 20:37:17 martin Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.23 2013/10/29 09:53:51 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.22 2013/10/25 20:37:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.23 2013/10/29 09:53:51 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -465,6 +465,13 @@ vflush(struct mount *mp, vnode_t *skipvp
 		 */
 		if (vp == skipvp)
 			continue;
+		/*
+		 * First try to recycle the vnode.
+		 */
+		if (vrecycle(vp, &mntvnode_lock)) {
+			mutex_enter(&mntvnode_lock);
+			continue;
+		}
 		mutex_enter(vp->v_interlock);
 		/*
 		 * Ignore clean but still referenced vnodes.
@@ -490,19 +497,6 @@ vflush(struct mount *mp, vnode_t *skipvp
 			continue;
 		}
 		/*
-		 * With v_usecount == 0, all we need to do is clear
-		 * out the vnode data structures and we are done.
-		 */
-		if (vp->v_usecount == 0) {
-			mutex_exit(&mntvnode_lock);
-			vremfree(vp);
-			vp->v_usecount = 1;
-			vclean(vp, DOCLOSE);
-			vrelel(vp, 0);
-			mutex_enter(&mntvnode_lock);
-			continue;
-		}
-		/*
 		 * If FORCECLOSE is set, forcibly close the vnode.
 		 * For block or character devices, revert to an
 		 * anonymous device.  For all other files, just
@@ -510,22 +504,8 @@ vflush(struct mount *mp, vnode_t *skipvp
 		 */
 		if (flags & FORCECLOSE) {
 			mutex_exit(&mntvnode_lock);
-			atomic_inc_uint(&vp->v_usecount);
-			if (vp->v_type != VBLK && vp->v_type != VCHR) {
-				vclean(vp, DOCLOSE);
-				vrelel(vp, 0);
-			} else {
-				vclean(vp, 0);
-				vp->v_op = spec_vnodeop_p; /* XXXSMP */
-				mutex_exit(vp->v_interlock);
-				/*
-				 * The vnode isn't clean, but still resides
-				 * on the mount list.  Remove it. XXX This
-				 * is a bit dodgy.
-				 */
-				vfs_insmntque(vp, NULL);
-				vrele(vp);
-			}
+			if (vget(vp, 0) == 0)
+				vgone(vp);
 			mutex_enter(&mntvnode_lock);
 			continue;
 		}
Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.22 src/sys/kern/vfs_vnode.c:1.23
--- src/sys/kern/vfs_vnode.c:1.22	Fri Oct 25 20:39:40 2013
+++ src/sys/kern/vfs_vnode.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.22 2013/10/25 20:39:40 martin Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.23 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -126,7 +126,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.22 2013/10/25 20:39:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.23 2013/10/29 09:53:51 hannken Exp $");
+
+#define _VFS_VNODE_PRIVATE
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -150,6 +152,15 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 #include <uvm/uvm.h>
 #include <uvm/uvm_readahead.h>
 
+/* v_usecount; see the comment near the top of vfs_vnode.c */
+#define	VC_XLOCK	0x80000000
+#define	VC_MASK		0x7fffffff
+
+#define	DOCLOSE		0x0008		/* vclean: close active files */
+
+/* Flags to vrelel. */
+#define	VRELEL_ASYNC_RELE	0x0001	/* Always defer to vrele thread. */
+
 u_int			numvnodes		__cacheline_aligned;
 
 static pool_cache_t	vnode_cache		__read_mostly;
@@ -172,6 +183,7 @@ static int		vrele_pending		__cacheline_a
 static int		vrele_gen		__cacheline_aligned;
 
 static int		cleanvnode(void);
+static void		vrelel(vnode_t *, int);
 static void		vdrain_thread(void *);
 static void		vrele_thread(void *);
 static void		vnpanic(vnode_t *, const char *, ...)
@@ -490,36 +502,6 @@ vremfree(vnode_t *vp)
 }
 
 /*
- * Try to gain a reference to a vnode, without acquiring its interlock.
- * The caller must hold a lock that will prevent the vnode from being
- * recycled or freed.
- */
-bool
-vtryget(vnode_t *vp)
-{
-	u_int use, next;
-
-	/*
-	 * If the vnode is being freed, don't make life any harder
-	 * for vclean() by adding another reference without waiting.
-	 * This is not strictly necessary, but we'll do it anyway.
-	 */
-	if (__predict_false((vp->v_iflag & VI_XLOCK) != 0)) {
-		return false;
-	}
-	for (use = vp->v_usecount;; use = next) {
-		if (use == 0 || __predict_false((use & VC_XLOCK) != 0)) {
-			/* Need interlock held if first reference. */
-			return false;
-		}
-		next = atomic_cas_uint(&vp->v_usecount, use, use + 1);
-		if (__predict_true(next == use)) {
-			return true;
-		}
-	}
-}
-
-/*
  * vget: get a particular vnode from the free list, increment its reference
  * count and lock it.
  *
@@ -634,7 +616,7 @@ vtryrele(vnode_t *vp)
  * Vnode release.  If reference count drops to zero, call inactive
  * routine and either return to freelist or free to the pool.
  */
-void
+static void
 vrelel(vnode_t *vp, int flags)
 {
 	bool recycle, defer;
@@ -980,7 +962,7 @@ void
 vclean(vnode_t *vp, int flags)
 {
 	lwp_t *l = curlwp;
-	bool recycle, active;
+	bool recycle, active, make_anon;
 	int error;
 
 	KASSERT(mutex_owned(vp->v_interlock));
@@ -1014,6 +996,11 @@ vclean(vnode_t *vp, int flags)
 	mutex_exit(vp->v_interlock);
 	VOP_LOCK(vp, LK_EXCLUSIVE);
 
+	make_anon = (active && vp->v_type == VBLK &&
+	    spec_node_getmountedfs(vp) != NULL);
+	if (make_anon)
+		flags &= ~DOCLOSE;
+
 	/*
 	 * Clean out any cached data associated with the vnode.
 	 * If purging an active vnode, it must be closed and
@@ -1061,9 +1048,20 @@ vclean(vnode_t *vp, int flags)
 	/* Purge name cache. */
 	cache_purge(vp);
 
+	/*
+	 * The vnode isn't clean, but still resides on the mount list.  Remove
+	 * it. XXX This is a bit dodgy.
+	 */
+	if (make_anon)
+		vfs_insmntque(vp, NULL);
+
 	/* Done with purge, notify sleepers of the grim news. */
 	mutex_enter(vp->v_interlock);
-	vp->v_op = dead_vnodeop_p;
+	if (make_anon) {
+		vp->v_op = spec_vnodeop_p;
+	} else {
+		vp->v_op = dead_vnodeop_p;
+	}
 	vp->v_tag = VT_NON;
 	KNOTE(&vp->v_klist, NOTE_REVOKE);
 	vp->v_iflag &= ~VI_XLOCK;
@@ -1081,7 +1079,7 @@ vclean(vnode_t *vp, int flags)
  * Release the passed interlock if the vnode will be recycled.
  */
 int
-vrecycle(vnode_t *vp, kmutex_t *inter_lkp, struct lwp *l)
+vrecycle(vnode_t *vp, kmutex_t *inter_lkp)
 {
 
 	KASSERT((vp->v_iflag & VI_MARKER) == 0);

Index: src/sys/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.102 src/sys/miscfs/procfs/procfs_subr.c:1.103
--- src/sys/miscfs/procfs/procfs_subr.c:1.102	Sun Nov 25 01:03:05 2012
+++ src/sys/miscfs/procfs/procfs_subr.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.102 2012/11/25 01:03:05 christos Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.103 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.102 2012/11/25 01:03:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.103 2013/10/29 09:53:51 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -671,18 +671,17 @@ procfs_revoke_vnodes(struct proc *p, voi
 	for (pfs = LIST_FIRST(ppp); pfs; pfs = pnext) {
 		vp = PFSTOV(pfs);
 		pnext = LIST_NEXT(pfs, pfs_hash);
+		if (pfs->pfs_pid != p->p_pid || vp->v_mount != mp)
+			continue;
 		mutex_enter(vp->v_interlock);
-		if (vp->v_usecount > 0 && pfs->pfs_pid == p->p_pid &&
-		    vp->v_mount == mp) {
-		    	vp->v_usecount++;
-		    	mutex_exit(vp->v_interlock);
-			mutex_exit(&pfs_ihash_lock);
-			VOP_REVOKE(vp, REVOKEALL);
-			vrele(vp);
+		mutex_exit(&pfs_ihash_lock);
+		if (vget(vp, 0) != 0) {
 			mutex_enter(&pfs_ihash_lock);
-		} else {
-			mutex_exit(vp->v_interlock);
+			continue;
 		}
+		VOP_REVOKE(vp, REVOKEALL);
+		vrele(vp);
+		mutex_enter(&pfs_ihash_lock);
 	}
 	mutex_exit(&pfs_ihash_lock);
 }

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.433 src/sys/sys/param.h:1.434
--- src/sys/sys/param.h:1.433	Mon Sep 30 18:58:00 2013
+++ src/sys/sys/param.h	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.433 2013/09/30 18:58:00 hannken Exp $	*/
+/*	$NetBSD: param.h,v 1.434 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -63,7 +63,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	699002400	/* NetBSD 6.99.24 */
+#define	__NetBSD_Version__	699002500	/* NetBSD 6.99.25 */
 
 #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.238 src/sys/sys/vnode.h:1.239
--- src/sys/sys/vnode.h:1.238	Mon Sep 30 15:24:14 2013
+++ src/sys/sys/vnode.h	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode.h,v 1.238 2013/09/30 15:24:14 hannken Exp $	*/
+/*	$NetBSD: vnode.h,v 1.239 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -205,8 +205,10 @@ typedef struct vnode vnode_t;
 #define	VI_LAYER	0x00020000	/* vnode is on a layer filesystem */
 #define	VI_LOCKSHARE	0x00040000	/* v_interlock is shared */
 #define	VI_CLEAN	0x00080000	/* has been reclaimed */
+#ifdef _VFS_VNODE_PRIVATE
 #define	VI_INACTREDO	0x00200000	/* need to redo VOP_INACTIVE() */
 #define	VI_INACTNOW	0x00800000	/* VOP_INACTIVE() in progress */
+#endif	/* _VFS_VNODE_PRIVATE */
 
 /*
  * The third set are locked by the underlying file system.
@@ -222,12 +224,6 @@ typedef struct vnode vnode_t;
 #define	VSIZENOTSET	((voff_t)-1)
 
 /*
- * v_usecount; see the comment near the top of vfs_vnode.c
- */
-#define	VC_XLOCK	0x80000000
-#define	VC_MASK		0x7fffffff
-
-/*
  * vnode lock flags
  */
 #define	LK_SHARED	0x00000001	/* shared lock */
@@ -318,7 +314,6 @@ extern const int	vttoif_tab[];
 #define	SKIPSYSTEM	0x0001		/* vflush: skip vnodes marked VSYSTEM */
 #define	FORCECLOSE	0x0002		/* vflush: force file closeure */
 #define	WRITECLOSE	0x0004		/* vflush: only close writable files */
-#define	DOCLOSE		0x0008		/* vclean: close active files */
 #define	V_SAVE		0x0001		/* vinvalbuf: sync file first */
 
 /*
@@ -548,12 +543,11 @@ int	vfinddev(dev_t, enum vtype, struct v
 int	vflush(struct mount *, struct vnode *, int);
 int	vflushbuf(struct vnode *, int);
 int 	vget(struct vnode *, int);
-bool	vtryget(struct vnode *);
 void 	vgone(struct vnode *);
 int	vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
 void	vprint(const char *, struct vnode *);
 void 	vput(struct vnode *);
-int	vrecycle(struct vnode *, kmutex_t *, struct lwp *);
+int	vrecycle(struct vnode *, kmutex_t *);
 void 	vrele(struct vnode *);
 void 	vrele_async(struct vnode *);
 void	vrele_flush(void);
@@ -562,8 +556,6 @@ void	vwakeup(struct buf *);
 void	vwait(struct vnode *, int);
 void	vclean(struct vnode *, int);
 void	vrevoke(struct vnode *);
-void	vrelel(struct vnode *, int);
-#define VRELEL_ASYNC_RELE	0x03
 struct vnode *
 	vnalloc(struct mount *);
 void	vnfree(struct vnode *);

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.173 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.174
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.173	Mon Sep 30 18:58:00 2013
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.173 2013/09/30 18:58:00 hannken Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.174 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.173 2013/09/30 18:58:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.174 2013/10/29 09:53:51 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -607,7 +607,7 @@ loop:
 		/*
 		 * Step 4: invalidate all inactive vnodes.
 		 */
-		if (vrecycle(vp, &mntvnode_lock, l)) {
+		if (vrecycle(vp, &mntvnode_lock)) {
 			mutex_enter(&mntvnode_lock);
 			(void)vunmark(mvp);
 			goto loop;

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.289 src/sys/ufs/ffs/ffs_vfsops.c:1.290
--- src/sys/ufs/ffs/ffs_vfsops.c:1.289	Mon Sep 30 18:58:00 2013
+++ src/sys/ufs/ffs/ffs_vfsops.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.289 2013/09/30 18:58:00 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.290 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.289 2013/09/30 18:58:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.290 2013/10/29 09:53:51 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -827,7 +827,7 @@ ffs_reload(struct mount *mp, kauth_cred_
 		/*
 		 * Step 4: invalidate all inactive vnodes.
 		 */
-		if (vrecycle(vp, &mntvnode_lock, l)) {
+		if (vrecycle(vp, &mntvnode_lock)) {
 			mutex_enter(&mntvnode_lock);
 			(void)vunmark(mvp);
 			goto loop;

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.232 src/sys/ufs/lfs/lfs_segment.c:1.233
--- src/sys/ufs/lfs/lfs_segment.c:1.232	Thu Oct 17 21:01:08 2013
+++ src/sys/ufs/lfs/lfs_segment.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.232 2013/10/17 21:01:08 christos Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.233 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.232 2013/10/17 21:01:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.233 2013/10/29 09:53:51 hannken Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {						\
@@ -2801,9 +2801,8 @@ lfs_vunref(struct vnode *vp)
 		return;
 	}
 
-	/* does not call inactive */
-	mutex_enter(vp->v_interlock);
-	vrelel(vp, 0);
+	/* does not call inactive XXX sure it does XXX */
+	vrele(vp);
 }
 
 /*
@@ -2820,9 +2819,9 @@ lfs_vunref_head(struct vnode *vp)
 
 	ASSERT_SEGLOCK(VTOI(vp)->i_lfs);
 
-	/* does not call inactive, inserts non-held vnode at head of freelist */
-	mutex_enter(vp->v_interlock);
-	vrelel(vp, 0);
+	/* does not call inactive XXX sure it does XXX,
+	   inserts non-held vnode at head of freelist */
+	vrele(vp);
 }
 
 

Index: src/sys/ufs/lfs/lfs_syscalls.c
diff -u src/sys/ufs/lfs/lfs_syscalls.c:1.149 src/sys/ufs/lfs/lfs_syscalls.c:1.150
--- src/sys/ufs/lfs/lfs_syscalls.c:1.149	Mon Oct  7 05:19:23 2013
+++ src/sys/ufs/lfs/lfs_syscalls.c	Tue Oct 29 09:53:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_syscalls.c,v 1.149 2013/10/07 05:19:23 dholland Exp $	*/
+/*	$NetBSD: lfs_syscalls.c,v 1.150 2013/10/29 09:53:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.149 2013/10/07 05:19:23 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.150 2013/10/29 09:53:51 hannken Exp $");
 
 #ifndef LFS
 # define LFS		/* for prototypes in syscallargs.h */
@@ -713,7 +713,7 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp,
 			if (v_daddr != LFS_UNUSED_DADDR) {
 				lfs_vunref(vp);
 				if (VTOI(vp)->i_lfs_iflags & LFSI_BMAP)
-					vrecycle(vp, NULL, NULL);
+					vrecycle(vp, NULL);
 				numrefed--;
 			}
 
@@ -823,7 +823,7 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp,
 		lfs_vunref(vp);
 		/* Recycle as above. */
 		if (ip->i_lfs_iflags & LFSI_BMAP)
-			vrecycle(vp, NULL, NULL);
+			vrecycle(vp, NULL);
 		numrefed--;
 	}
 

Reply via email to