Index: nfsclient/nfs_bio.c
===================================================================
RCS file: /data/ncvs/src/sys/nfsclient/nfs_bio.c,v
retrieving revision 1.117
diff -u -r1.117 nfs_bio.c
--- nfsclient/nfs_bio.c	4 Mar 2003 00:04:43 -0000	1.117
+++ nfsclient/nfs_bio.c	10 May 2003 14:05:59 -0000
@@ -1063,6 +1063,8 @@
 	struct nfsmount *nmp = VFSTONFS(vp->v_mount);
 	int error = 0, slpflag, slptimeo;
 
+	ASSERT_VOP_LOCKED(vp, "nfs_vinvalbuf");
+
 	VI_LOCK(vp);
 	if (vp->v_iflag & VI_XLOCK) {
 		/* XXX Should we wait here? */
@@ -1344,7 +1346,7 @@
 			uiop->uio_resid = 0;
 		    }
 		}
-		ASSERT_VOP_LOCKED(vp, "nfs_doio");
+		/* ASSERT_VOP_LOCKED(vp, "nfs_doio"); */
 		if (p && (vp->v_vflag & VV_TEXT) &&
 			(np->n_mtime != np->n_vattr.va_mtime.tv_sec)) {
 			uprintf("Process killed due to text file modification\n");
Index: nfsclient/nfs_vnops.c
===================================================================
RCS file: /data/ncvs/src/sys/nfsclient/nfs_vnops.c,v
retrieving revision 1.204
diff -u -r1.204 nfs_vnops.c
--- nfsclient/nfs_vnops.c	24 Apr 2003 20:39:40 -0000	1.204
+++ nfsclient/nfs_vnops.c	10 May 2003 15:07:23 -0000
@@ -526,7 +526,9 @@
 		    error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_td, cm);
 		    /* np->n_flag &= ~NMODIFIED; */
 		} else {
+		    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
 		    error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1);
+		    VOP_UNLOCK(vp, 0, ap->a_td);
 		}
 		np->n_attrstamp = 0;
 	    }
@@ -3131,7 +3133,9 @@
 				vattr.va_atime = np->n_atim;
 			if (np->n_flag & NUPD)
 				vattr.va_mtime = np->n_mtim;
+			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
 			(void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td);
+			VOP_UNLOCK(vp, 0, ap->a_td);
 		}
 	}
 	return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
Index: fs/fifofs/fifo_vnops.c
===================================================================
RCS file: /data/ncvs/src/sys/fs/fifofs/fifo_vnops.c,v
retrieving revision 1.85
diff -u -r1.85 fifo_vnops.c
--- fs/fifofs/fifo_vnops.c	24 Mar 2003 11:03:42 -0000	1.85
+++ fs/fifofs/fifo_vnops.c	10 May 2003 15:05:25 -0000
@@ -66,6 +66,8 @@
 	long		fi_writers;
 };
 
+static int	fifo_cleanup(struct vnode *vp, int fflags);
+
 static int	fifo_print(struct vop_print_args *);
 static int	fifo_lookup(struct vop_lookup_args *);
 static int	fifo_open(struct vop_open_args *);
@@ -154,6 +156,40 @@
 }
 
 /*
+ * Cleanup when we no longer need a fifo.  May be called with or without
+ * the vnode lock--with the lock in the open() case, and without in the
+ * close() case.
+ */
+static int
+fifo_cleanup(struct vnode *vp, int fflag)
+{
+	register struct fifoinfo *fip = vp->v_fifoinfo;
+	int error1, error2;
+
+	if (fflag & FREAD) {
+		fip->fi_readers--;
+		if (fip->fi_readers == 0)
+			socantsendmore(fip->fi_writesock);
+	}
+	if (fflag & FWRITE) {
+		fip->fi_writers--;
+		if (fip->fi_writers == 0)
+			socantrcvmore(fip->fi_readsock);
+	}
+
+	if (vrefcnt(vp) > 1)
+		return (0);
+
+	error1 = soclose(fip->fi_readsock);
+	error2 = soclose(fip->fi_writesock);
+	FREE(fip, M_VNODE);
+	vp->v_fifoinfo = NULL;
+	if (error1)
+		return (error1);
+	return (error2);
+}
+
+/*
  * Open called to set up a new instance of a fifo or
  * to find an active instance of a fifo.
  */
@@ -264,7 +300,7 @@
 	}
 	return (0);
 bad:
-	VOP_CLOSE(vp, ap->a_mode, ap->a_cred, td);
+	fifo_cleanup(vp, ap->a_mode);
 	return (error);
 }
 
@@ -525,29 +561,8 @@
 		struct thread *a_td;
 	} */ *ap;
 {
-	register struct vnode *vp = ap->a_vp;
-	register struct fifoinfo *fip = vp->v_fifoinfo;
-	int error1, error2;
 
-	if (ap->a_fflag & FREAD) {
-		fip->fi_readers--;
-		if (fip->fi_readers == 0)
-			socantsendmore(fip->fi_writesock);
-	}
-	if (ap->a_fflag & FWRITE) {
-		fip->fi_writers--;
-		if (fip->fi_writers == 0)
-			socantrcvmore(fip->fi_readsock);
-	}
-	if (vrefcnt(vp) > 1)
-		return (0);
-	error1 = soclose(fip->fi_readsock);
-	error2 = soclose(fip->fi_writesock);
-	FREE(fip, M_VNODE);
-	vp->v_fifoinfo = NULL;
-	if (error1)
-		return (error1);
-	return (error2);
+	return (fifo_cleanup(ap->a_vp, ap->a_fflag));
 }
 
 
