Module Name:    src
Committed By:   tls
Date:           Sun Aug 10 06:56:45 UTC 2014

Modified Files:
        src/sys/nfs [tls-earlyentropy]: nfs.h nfs_node.c nfs_socket.c
            nfs_subs.c nfs_var.h nfs_vfsops.c nfs_vnops.c nfsmount.h nfsnode.h

Log Message:
Rebase.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.73.10.1 src/sys/nfs/nfs.h
cvs rdiff -u -r1.117 -r1.117.2.1 src/sys/nfs/nfs_node.c
cvs rdiff -u -r1.190 -r1.190.2.1 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.225.2.1 -r1.225.2.2 src/sys/nfs/nfs_subs.c
cvs rdiff -u -r1.91 -r1.91.2.1 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.226 -r1.226.2.1 src/sys/nfs/nfs_vfsops.c
cvs rdiff -u -r1.304 -r1.304.2.1 src/sys/nfs/nfs_vnops.c
cvs rdiff -u -r1.51 -r1.51.28.1 src/sys/nfs/nfsmount.h
cvs rdiff -u -r1.72 -r1.72.32.1 src/sys/nfs/nfsnode.h

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

Modified files:

Index: src/sys/nfs/nfs.h
diff -u src/sys/nfs/nfs.h:1.73 src/sys/nfs/nfs.h:1.73.10.1
--- src/sys/nfs/nfs.h:1.73	Fri Mar  1 18:26:10 2013
+++ src/sys/nfs/nfs.h	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.h,v 1.73 2013/03/01 18:26:10 joerg Exp $	*/
+/*	$NetBSD: nfs.h,v 1.73.10.1 2014/08/10 06:56:45 tls Exp $	*/
 /*
  * Copyright (c) 1989, 1993, 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -238,39 +238,39 @@ struct mountd_exports_list {
  * Stats structure
  */
 struct nfsstats {
-	int	attrcache_hits;
-	int	attrcache_misses;
-	int	lookupcache_hits;
-	int	lookupcache_misses;
-	int	direofcache_hits;
-	int	direofcache_misses;
-	int	biocache_reads;
-	int	read_bios;
-	int	read_physios;
-	int	biocache_writes;
-	int	write_bios;
-	int	write_physios;
-	int	biocache_readlinks;
-	int	readlink_bios;
-	int	biocache_readdirs;
-	int	readdir_bios;
-	int	rpccnt[NFSSTATS_NPROCS];
-	int	rpcretries;
-	int	srvrpccnt[NFSSTATS_NPROCS];
-	int	srvrpc_errs;
-	int	srv_errs;
-	int	rpcrequests;
-	int	rpctimeouts;
-	int	rpcunexpected;
-	int	rpcinvalid;
-	int	srvcache_inproghits;
-	int	srvcache_idemdonehits;
-	int	srvcache_nonidemdonehits;
-	int	srvcache_misses;
-	int	__srvnqnfs_leases;	/* unused */
-	int	__srvnqnfs_maxleases;	/* unused */
-	int	__srvnqnfs_getleases;	/* unused */
-	int	srvvop_writes;
+	uint32_t	attrcache_hits;
+	uint32_t	attrcache_misses;
+	uint32_t	lookupcache_hits;
+	uint32_t	lookupcache_misses;
+	uint32_t	direofcache_hits;
+	uint32_t	direofcache_misses;
+	uint32_t	biocache_reads;
+	uint32_t	read_bios;
+	uint32_t	read_physios;
+	uint32_t	biocache_writes;
+	uint32_t	write_bios;
+	uint32_t	write_physios;
+	uint32_t	biocache_readlinks;
+	uint32_t	readlink_bios;
+	uint32_t	biocache_readdirs;
+	uint32_t	readdir_bios;
+	uint32_t	rpccnt[NFSSTATS_NPROCS];
+	uint32_t	rpcretries;
+	uint32_t	srvrpccnt[NFSSTATS_NPROCS];
+	uint32_t	srvrpc_errs;
+	uint32_t	srv_errs;
+	uint32_t	rpcrequests;
+	uint32_t	rpctimeouts;
+	uint32_t	rpcunexpected;
+	uint32_t	rpcinvalid;
+	uint32_t	srvcache_inproghits;
+	uint32_t	srvcache_idemdonehits;
+	uint32_t	srvcache_nonidemdonehits;
+	uint32_t	srvcache_misses;
+	uint32_t	__srvnqnfs_leases;	/* unused */
+	uint32_t	__srvnqnfs_maxleases;	/* unused */
+	uint32_t	__srvnqnfs_getleases;	/* unused */
+	uint32_t	srvvop_writes;
 };
 
 /*

Index: src/sys/nfs/nfs_node.c
diff -u src/sys/nfs/nfs_node.c:1.117 src/sys/nfs/nfs_node.c:1.117.2.1
--- src/sys/nfs/nfs_node.c:1.117	Thu Feb 27 16:51:38 2014
+++ src/sys/nfs/nfs_node.c	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_node.c,v 1.117 2014/02/27 16:51:38 hannken Exp $	*/
+/*	$NetBSD: nfs_node.c,v 1.117.2.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.117 2014/02/27 16:51:38 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.117.2.1 2014/08/10 06:56:45 tls Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -106,120 +106,36 @@ nfs_node_done(void)
 	workqueue_destroy(nfs_sillyworkq);
 }
 
-struct fh_match {
-	nfsfh_t *fhm_fhp;
-	size_t fhm_fhsize;
-	size_t fhm_fhoffset;
-};
-
-static int
-nfs_compare_nodes(void *ctx, const void *parent, const void *node)
-{
-	const struct nfsnode * const pnp = parent;
-	const struct nfsnode * const np = node;
-
-	if (pnp->n_fhsize != np->n_fhsize)
-		return np->n_fhsize - pnp->n_fhsize;
-
-	return memcmp(np->n_fhp, pnp->n_fhp, np->n_fhsize);
-}
-
-static int
-nfs_compare_node_fh(void *ctx, const void *b, const void *key)
-{
-	const struct nfsnode * const pnp = b;
-	const struct fh_match * const fhm = key;
-
-	if (pnp->n_fhsize != fhm->fhm_fhsize)
-		return fhm->fhm_fhsize - pnp->n_fhsize;
-
-	return memcmp(fhm->fhm_fhp, pnp->n_fhp, pnp->n_fhsize);
-}
-
-static const rb_tree_ops_t nfs_node_rbtree_ops = {
-	.rbto_compare_nodes = nfs_compare_nodes,
-	.rbto_compare_key = nfs_compare_node_fh,
-	.rbto_node_offset = offsetof(struct nfsnode, n_rbnode),
-	.rbto_context = NULL
-};
-
-void
-nfs_rbtinit(struct nfsmount *nmp)
-{
-
-	rb_tree_init(&nmp->nm_rbtree, &nfs_node_rbtree_ops);
-}
-
 /*
- * Look up a vnode/nfsnode by file handle.
- * Callers must check for mount points!!
- * In all cases, a pointer to a
- * nfsnode structure is returned.
+ * Initialize this vnode / nfs node pair.
+ * Caller assures no other thread will try to load this node.
  */
 int
-nfs_nget1(struct mount *mntp, nfsfh_t *fhp, int fhsize, struct nfsnode **npp,
-    int lkflags)
+nfs_loadvnode(struct mount *mp, struct vnode *vp,
+    const void *key, size_t key_len, const void **new_key)
 {
+	int fhsize = key_len;
+	const nfsfh_t *fhp = key;
 	struct nfsnode *np;
-	struct vnode *vp;
-	struct nfsmount *nmp = VFSTONFS(mntp);
-	int error;
-	struct fh_match fhm;
-
-	fhm.fhm_fhp = fhp;
-	fhm.fhm_fhsize = fhsize;
 
-loop:
-	rw_enter(&nmp->nm_rbtlock, RW_READER);
-	np = rb_tree_find_node(&nmp->nm_rbtree, &fhm);
-	if (np != NULL) {
-		vp = NFSTOV(np);
-		mutex_enter(vp->v_interlock);
-		rw_exit(&nmp->nm_rbtlock);
-		error = vget(vp, LK_EXCLUSIVE | lkflags);
-		if (error == EBUSY)
-			return error;
-		if (error)
-			goto loop;
-		*npp = np;
-		return(0);
-	}
-	rw_exit(&nmp->nm_rbtlock);
-
-	error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, NULL, &vp);
-	if (error) {
-		*npp = 0;
-		return (error);
-	}
+	/* Aloocate and initialize the nfsnode. */
 	np = pool_get(&nfs_node_pool, PR_WAITOK);
 	memset(np, 0, sizeof *np);
-	np->n_vnode = vp;
-
-	/*
-	 * Insert the nfsnode in the hash queue for its new file handle
-	 */
-
 	if (fhsize > NFS_SMALLFH) {
 		np->n_fhp = kmem_alloc(fhsize, KM_SLEEP);
 	} else
 		np->n_fhp = &np->n_fh;
+	vp->v_tag = VT_NFS;
+	vp->v_type = VNON;
+	vp->v_op = nfsv2_vnodeop_p;
+	vp->v_data = np;
 	memcpy(np->n_fhp, fhp, fhsize);
 	np->n_fhsize = fhsize;
 	np->n_accstamp = -1;
 	np->n_vattr = pool_get(&nfs_vattr_pool, PR_WAITOK);
+	np->n_vnode = vp;
 
-	rw_enter(&nmp->nm_rbtlock, RW_WRITER);
-	if (NULL != rb_tree_find_node(&nmp->nm_rbtree, &fhm)) {
-		rw_exit(&nmp->nm_rbtlock);
-		if (fhsize > NFS_SMALLFH) {
-			kmem_free(np->n_fhp, fhsize);
-		}
-		pool_put(&nfs_vattr_pool, np->n_vattr);
-		pool_put(&nfs_node_pool, np);
-		ungetnewvnode(vp);
-		goto loop;
-	}
-	vp->v_data = np;
+	/* Initialize genfs node. */
 	genfs_node_init(vp, &nfs_genfsops);
 	/*
 	 * Initalize read/write creds to useful values. VOP_OPEN will
@@ -229,15 +145,35 @@ loop:
 	kauth_cred_hold(np->n_rcred);
 	np->n_wcred = curlwp->l_cred;
 	kauth_cred_hold(np->n_wcred);
-	error = VOP_LOCK(vp, LK_EXCLUSIVE);
-	KASSERT(error == 0);
 	NFS_INVALIDATE_ATTRCACHE(np);
 	uvm_vnp_setsize(vp, 0);
-	(void)rb_tree_insert_node(&nmp->nm_rbtree, np);
-	rw_exit(&nmp->nm_rbtlock);
+	*new_key = np->n_fhp;
+	return 0;
+}
 
-	*npp = np;
-	return (0);
+/*
+ * Look up a vnode/nfsnode by file handle.
+ * Callers must check for mount points!!
+ * In all cases, a pointer to a
+ * nfsnode structure is returned.
+ */
+int
+nfs_nget1(struct mount *mntp, nfsfh_t *fhp, int fhsize, struct nfsnode **npp,
+    int lkflags)
+{
+	int error;
+	struct vnode *vp;
+
+	error = vcache_get(mntp, fhp, fhsize, &vp);
+	if (error)
+		return error;
+	error = vn_lock(vp, LK_EXCLUSIVE | lkflags);
+	if (error) {
+		vrele(vp);
+		return error;
+	}
+	*npp = VTONFS(vp);
+	return 0;
 }
 
 int
@@ -287,14 +223,11 @@ nfs_reclaim(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
 	struct nfsnode *np = VTONFS(vp);
-	struct nfsmount *nmp = VFSTONFS(vp->v_mount);
 
 	if (prtactive && vp->v_usecount > 1)
 		vprint("nfs_reclaim: pushing active", vp);
 
-	rw_enter(&nmp->nm_rbtlock, RW_WRITER);
-	rb_tree_remove_node(&nmp->nm_rbtree, np);
-	rw_exit(&nmp->nm_rbtlock);
+	vcache_remove(vp->v_mount, np->n_fhp, np->n_fhsize);
 
 	/*
 	 * Free up any directory cookie structures and

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.190 src/sys/nfs/nfs_socket.c:1.190.2.1
--- src/sys/nfs/nfs_socket.c:1.190	Sat Sep 14 22:29:08 2013
+++ src/sys/nfs/nfs_socket.c	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.190 2013/09/14 22:29:08 martin Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.190.2.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.190 2013/09/14 22:29:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.190.2.1 2014/08/10 06:56:45 tls Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -805,11 +805,11 @@ nfs_timer(void *arg)
 		    nmp->nm_sent < nmp->nm_cwnd) &&
 		   (m = m_copym(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT))){
 		        if (so->so_state & SS_ISCONNECTED)
-			    error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
-			    NULL, NULL, NULL);
+			    error = (*so->so_proto->pr_usrreqs->pr_send)(so,
+			    m, NULL, NULL, NULL);
 			else
-			    error = (*so->so_proto->pr_usrreq)(so, PRU_SEND, m,
-			    nmp->nm_nam, NULL, NULL);
+			    error = (*so->so_proto->pr_usrreqs->pr_send)(so,
+			    m, nmp->nm_nam, NULL, NULL);
 			if (error) {
 				if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) {
 #ifdef DEBUG

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.225.2.1 src/sys/nfs/nfs_subs.c:1.225.2.2
--- src/sys/nfs/nfs_subs.c:1.225.2.1	Thu Jul 17 14:03:33 2014
+++ src/sys/nfs/nfs_subs.c	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.225.2.1 2014/07/17 14:03:33 tls Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.225.2.2 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.225.2.1 2014/07/17 14:03:33 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.225.2.2 2014/08/10 06:56:45 tls Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1742,6 +1742,30 @@ netaddr_match(int family, union nethosta
 	return (0);
 }
 
+struct nfs_clearcommit_ctx {
+	struct mount *mp;
+};
+
+static bool
+nfs_clearcommit_selector(void *cl, struct vnode *vp)
+{
+	struct nfs_clearcommit_ctx *c = cl;
+	struct nfsnode *np;
+	struct vm_page *pg;
+
+	np = VTONFS(vp);
+	if (vp->v_type != VREG || vp->v_mount != c->mp || np == NULL)
+		return false;
+	np->n_pushlo = np->n_pushhi = np->n_pushedlo =
+	    np->n_pushedhi = 0;
+	np->n_commitflags &=
+	    ~(NFS_COMMIT_PUSH_VALID | NFS_COMMIT_PUSHED_VALID);
+	TAILQ_FOREACH(pg, &vp->v_uobj.memq, listq.queue) {
+		pg->flags &= ~PG_NEEDCOMMIT;
+	}
+	return false;
+}
+
 /*
  * The write verifier has changed (probably due to a server reboot), so all
  * PG_NEEDCOMMIT pages will have to be written again. Since they are marked
@@ -1752,32 +1776,16 @@ netaddr_match(int family, union nethosta
 void
 nfs_clearcommit(struct mount *mp)
 {
-	struct vnode *vp;
+	struct vnode *vp __diagused;
 	struct vnode_iterator *marker;
-	struct nfsnode *np;
-	struct vm_page *pg;
 	struct nfsmount *nmp = VFSTONFS(mp);
+	struct nfs_clearcommit_ctx ctx;
 
 	rw_enter(&nmp->nm_writeverflock, RW_WRITER);
 	vfs_vnode_iterator_init(mp, &marker);
-	while (vfs_vnode_iterator_next(marker, &vp)) {
-		mutex_enter(vp->v_interlock);
-		np = VTONFS(vp);
-		if (vp->v_type != VREG || vp->v_mount != mp || np == NULL) {
-			mutex_exit(vp->v_interlock);
-			vrele(vp);
-			continue;
-		}
-		np->n_pushlo = np->n_pushhi = np->n_pushedlo =
-		    np->n_pushedhi = 0;
-		np->n_commitflags &=
-		    ~(NFS_COMMIT_PUSH_VALID | NFS_COMMIT_PUSHED_VALID);
-		TAILQ_FOREACH(pg, &vp->v_uobj.memq, listq.queue) {
-			pg->flags &= ~PG_NEEDCOMMIT;
-		}
-		mutex_exit(vp->v_interlock);
-		vrele(vp);
-	}
+	ctx.mp = mp;
+	vp = vfs_vnode_iterator_next(marker, nfs_clearcommit_selector, &ctx);
+	KASSERT(vp == NULL);
 	vfs_vnode_iterator_destroy(marker);
 	mutex_enter(&nmp->nm_lock);
 	nmp->nm_iflag &= ~NFSMNT_STALEWRITEVERF;

Index: src/sys/nfs/nfs_var.h
diff -u src/sys/nfs/nfs_var.h:1.91 src/sys/nfs/nfs_var.h:1.91.2.1
--- src/sys/nfs/nfs_var.h:1.91	Sat Dec 14 16:19:28 2013
+++ src/sys/nfs/nfs_var.h	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_var.h,v 1.91 2013/12/14 16:19:28 christos Exp $	*/
+/*	$NetBSD: nfs_var.h,v 1.91.2.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -80,7 +80,6 @@ void nfs_kqinit(void);
 void nfs_kqfini(void);
 
 /* nfs_node.c */
-void nfs_rbtinit(struct nfsmount *);
 void nfs_node_init(void);
 void nfs_node_done(void);
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.226 src/sys/nfs/nfs_vfsops.c:1.226.2.1
--- src/sys/nfs/nfs_vfsops.c:1.226	Sun Mar 23 15:21:16 2014
+++ src/sys/nfs/nfs_vfsops.c	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.226 2014/03/23 15:21:16 hannken Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.226.2.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.226 2014/03/23 15:21:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.226.2.1 2014/08/10 06:56:45 tls Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -113,6 +113,7 @@ struct vfsops nfs_vfsops = {
 	.vfs_quotactl = (void *)eopnotsupp,
 	.vfs_statvfs = nfs_statvfs,
 	.vfs_sync = nfs_sync,
+	.vfs_loadvnode = nfs_loadvnode,
 	.vfs_vget = nfs_vget,
 	.vfs_fhtovp = nfs_fhtovp,
 	.vfs_vptofh = nfs_vptofh,
@@ -594,6 +595,8 @@ nfs_mount(struct mount *mp, const char *
 	size_t len;
 	u_char *nfh;
 
+	if (args == NULL)
+		return EINVAL;
 	if (*data_len < sizeof *args)
 		return EINVAL;
 
@@ -719,12 +722,10 @@ mountnfs(struct nfs_args *argp, struct m
 		TAILQ_INIT(&nmp->nm_bufq);
 		rw_init(&nmp->nm_writeverflock);
 		mutex_init(&nmp->nm_lock, MUTEX_DEFAULT, IPL_NONE);
-		rw_init(&nmp->nm_rbtlock);
 		cv_init(&nmp->nm_rcvcv, "nfsrcv");
 		cv_init(&nmp->nm_sndcv, "nfssnd");
 		cv_init(&nmp->nm_aiocv, "nfsaio");
 		cv_init(&nmp->nm_disconcv, "nfsdis");
-		nfs_rbtinit(nmp);
 	}
 	vfs_getnewfsid(mp);
 	nmp->nm_mountp = mp;
@@ -824,7 +825,6 @@ mountnfs(struct nfs_args *argp, struct m
 bad:
 	nfs_disconnect(nmp);
 	rw_destroy(&nmp->nm_writeverflock);
-	rw_destroy(&nmp->nm_rbtlock);
 	mutex_destroy(&nmp->nm_lock);
 	cv_destroy(&nmp->nm_rcvcv);
 	cv_destroy(&nmp->nm_sndcv);
@@ -901,7 +901,6 @@ nfs_unmount(struct mount *mp, int mntfla
 	m_freem(nmp->nm_nam);
 
 	rw_destroy(&nmp->nm_writeverflock);
-	rw_destroy(&nmp->nm_rbtlock);
 	mutex_destroy(&nmp->nm_lock);
 	cv_destroy(&nmp->nm_rcvcv);
 	cv_destroy(&nmp->nm_sndcv);
@@ -935,6 +934,13 @@ nfs_root(struct mount *mp, struct vnode 
 
 extern int syncprt;
 
+static bool
+nfs_sync_selector(void *cl, struct vnode *vp)
+{
+
+	return !LIST_EMPTY(&vp->v_dirtyblkhd) || !UVM_OBJ_IS_CLEAN(&vp->v_uobj);
+}
+
 /*
  * Flush out the buffer cache
  */
@@ -950,17 +956,14 @@ nfs_sync(struct mount *mp, int waitfor, 
 	 * Force stale buffer cache information to be flushed.
 	 */
 	vfs_vnode_iterator_init(mp, &marker);
-	while (vfs_vnode_iterator_next(marker, &vp)) {
+	while ((vp = vfs_vnode_iterator_next(marker, nfs_sync_selector,
+	    NULL)))
+	{
 		error = vn_lock(vp, LK_EXCLUSIVE);
 		if (error) {
 			vrele(vp);
 			continue;
 		}
-		if (LIST_EMPTY(&vp->v_dirtyblkhd) &&
-		    UVM_OBJ_IS_CLEAN(&vp->v_uobj)) {
-			vput(vp);
-			continue;
-		}
 		error = VOP_FSYNC(vp, cred,
 		    waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0);
 		if (error)

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.304 src/sys/nfs/nfs_vnops.c:1.304.2.1
--- src/sys/nfs/nfs_vnops.c:1.304	Fri Feb  7 15:29:22 2014
+++ src/sys/nfs/nfs_vnops.c	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.304 2014/02/07 15:29:22 hannken Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.304.2.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.304 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.304.2.1 2014/08/10 06:56:45 tls Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -107,6 +107,8 @@ const struct vnodeopv_entry_desc nfsv2_v
 	{ &vop_setattr_desc, nfs_setattr },		/* setattr */
 	{ &vop_read_desc, nfs_read },			/* read */
 	{ &vop_write_desc, nfs_write },			/* write */
+	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
+	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, nfs_ioctl },			/* ioctl */
 	{ &vop_poll_desc, nfs_poll },			/* poll */
@@ -158,6 +160,8 @@ const struct vnodeopv_entry_desc spec_nf
 	{ &vop_setattr_desc, nfs_setattr },		/* setattr */
 	{ &vop_read_desc, nfsspec_read },		/* read */
 	{ &vop_write_desc, nfsspec_write },		/* write */
+	{ &vop_fallocate_desc, spec_fallocate },	/* fallocate */
+	{ &vop_fdiscard_desc, spec_fdiscard },		/* fdiscard */
 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
 	{ &vop_poll_desc, spec_poll },			/* poll */
@@ -206,6 +210,8 @@ const struct vnodeopv_entry_desc fifo_nf
 	{ &vop_setattr_desc, nfs_setattr },		/* setattr */
 	{ &vop_read_desc, nfsfifo_read },		/* read */
 	{ &vop_write_desc, nfsfifo_write },		/* write */
+	{ &vop_fallocate_desc, vn_fifo_bypass },	/* fallocate */
+	{ &vop_fdiscard_desc, vn_fifo_bypass },		/* fdiscard */
 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
 	{ &vop_ioctl_desc, vn_fifo_bypass },		/* ioctl */
 	{ &vop_poll_desc, vn_fifo_bypass },		/* poll */
@@ -2943,12 +2949,12 @@ nfs_lookitup(struct vnode *dvp, const ch
 	struct vnode *newvp = (struct vnode *)0;
 	struct nfsnode *np, *dnp = VTONFS(dvp);
 	char *bpos, *dpos, *cp2;
-	int error = 0, fhlen;
+	int error = 0, ofhlen, fhlen;
 #ifndef NFS_V2_ONLY
 	int attrflag;
 #endif
 	struct mbuf *mreq, *mrep, *md, *mb;
-	nfsfh_t *nfhp;
+	nfsfh_t *ofhp, *nfhp;
 	const int v3 = NFS_ISV3(dvp);
 
 	nfsstats.rpccnt[NFSPROC_LOOKUP]++;
@@ -2961,6 +2967,17 @@ nfs_lookitup(struct vnode *dvp, const ch
 		nfsm_getfh(nfhp, fhlen, v3);
 		if (*npp) {
 		    np = *npp;
+		    newvp = NFSTOV(np);
+		    ofhlen = np->n_fhsize;
+		    ofhp = kmem_alloc(ofhlen, KM_SLEEP);
+		    memcpy(ofhp, np->n_fhp, ofhlen);
+		    error = vcache_rekey_enter(newvp->v_mount, newvp,
+			ofhp, ofhlen, nfhp, fhlen);
+		    if (error) {
+			kmem_free(ofhp, ofhlen);
+			m_freem(mrep);
+			return error;
+		    }
 		    if (np->n_fhsize > NFS_SMALLFH && fhlen <= NFS_SMALLFH) {
 			kmem_free(np->n_fhp, np->n_fhsize);
 			np->n_fhp = &np->n_fh;
@@ -2971,7 +2988,9 @@ nfs_lookitup(struct vnode *dvp, const ch
 #endif
 		    memcpy(np->n_fhp, nfhp, fhlen);
 		    np->n_fhsize = fhlen;
-		    newvp = NFSTOV(np);
+		    vcache_rekey_exit(newvp->v_mount, newvp,
+			ofhp, ofhlen, np->n_fhp, fhlen);
+		    kmem_free(ofhp, ofhlen);
 		} else if (NFS_CMPFH(dnp, nfhp, fhlen)) {
 		    vref(dvp);
 		    newvp = dvp;

Index: src/sys/nfs/nfsmount.h
diff -u src/sys/nfs/nfsmount.h:1.51 src/sys/nfs/nfsmount.h:1.51.28.1
--- src/sys/nfs/nfsmount.h:1.51	Sat Jan 22 22:26:10 2011
+++ src/sys/nfs/nfsmount.h	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsmount.h,v 1.51 2011/01/22 22:26:10 matt Exp $	*/
+/*	$NetBSD: nfsmount.h,v 1.51.28.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -43,7 +43,6 @@
 #include <sys/rwlock.h>
 #include <sys/mutex.h>
 #include <sys/disk.h>
-#include <sys/rbtree.h>
 #endif
 
 /*
@@ -130,7 +129,6 @@ struct nfs_args {
  */
 struct	nfsmount {
 	kmutex_t nm_lock;		/* Lock for this structure */
-	krwlock_t nm_rbtlock;		/* Lock for the rbtree */
 	kcondvar_t nm_rcvcv;
 	kcondvar_t nm_sndcv;
 	int	nm_flag;		/* Flags for soft/hard... */
@@ -138,7 +136,6 @@ struct	nfsmount {
 	int	nm_numgrps;		/* Max. size of groupslist */
 	struct	vnode *nm_vnode;
 	struct	socket *nm_so;		/* Rpc socket */
-	struct	rb_tree nm_rbtree;	/* red/black tree by fh for nfsnode */
 	int	nm_sotype;		/* Type of socket */
 	int	nm_soproto;		/* and protocol */
 	int	nm_soflags;		/* pr_flags for socket protocol */

Index: src/sys/nfs/nfsnode.h
diff -u src/sys/nfs/nfsnode.h:1.72 src/sys/nfs/nfsnode.h:1.72.32.1
--- src/sys/nfs/nfsnode.h:1.72	Sat Sep 25 01:42:39 2010
+++ src/sys/nfs/nfsnode.h	Sun Aug 10 06:56:45 2014
@@ -1,4 +1,4 @@
-/*	 $NetBSD: nfsnode.h,v 1.72 2010/09/25 01:42:39 matt Exp $	*/
+/*	 $NetBSD: nfsnode.h,v 1.72.32.1 2014/08/10 06:56:45 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -40,7 +40,6 @@
 
 #include <sys/condvar.h>
 #include <sys/mutex.h>
-#include <sys/rbtree.h>
 
 #ifndef _NFS_NFS_H_
 #include <nfs/nfs.h>
@@ -153,7 +152,6 @@ struct nfsnode {
 #define n_sillyrename	n_un2.nf_silly
 #define n_dirgens	n_un2.ndir_dirgens
 
-	struct rb_node		n_rbnode;	/* red/black node */
 	nfsfh_t			*n_fhp;		/* NFS File Handle */
 	struct vattr		*n_vattr;	/* Vnode attribute cache */
 	struct vnode		*n_vnode;	/* associated vnode */

Reply via email to