Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 1996 13:17:25 +0100 (BST)
From:      Doug Rabson <dfr@render.com>
To:        Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
Cc:        henrich@crh.cl.msu.edu, lite2@freebsd.org
Subject:   Re: Delayed write patch
Message-ID:  <Pine.BSF.3.95.961010131427.10204p-100000@minnow.render.com>
In-Reply-To: <1519.844933124@sat.t.u-tokyo.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for the patch.  It improves performance for my SGI from ~720k/sec
to ~870k/sec.  I modified the patch (and the nfs_dwrite patch) slightly
and added comments to try to explain what is happening.  Could you check
the comments to make sure they agree with your understanding of the
problem and I will commit this patch to current probably tomorrow.

Index: nfs_bio.c
===================================================================
RCS file: /home/ncvs/src/sys/nfs/nfs_bio.c,v
retrieving revision 1.25
diff -u -r1.25 nfs_bio.c
--- nfs_bio.c	1996/09/19 18:20:54	1.25
+++ nfs_bio.c	1996/10/10 12:13:00
@@ -46,6 +46,7 @@
 #include <sys/vnode.h>
 #include <sys/mount.h>
 #include <sys/kernel.h>
+#include <sys/sysctl.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
@@ -65,6 +66,9 @@
 extern int nfs_numasync;
 extern struct nfsstats nfsstats;
 
+int nfs_dwrite = 1;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, dwrite, CTLFLAG_RW, &nfs_dwrite, 0, "");
+
 /*
  * Ifdefs for FreeBSD-current's merged VM/buffer cache. It is unfortunate
  * that this isn't done inside getblk() and brelse() so these calls
@@ -750,6 +754,14 @@
 	 * synchronously.
 	 */
 	if (bp->b_flags & (B_READ | B_WRITEINPROG | B_NOCACHE))
+		return (EIO);
+
+	/*
+	 * Allow the administrator to override the choice of using a delayed
+	 * write since it is a pessimization for some servers, notably some
+	 * Solaris servers.
+	 */
+	if (!nfs_dwrite)
 		return (EIO);
 
 	/*
Index: nfs_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/nfs/nfs_socket.c,v
retrieving revision 1.17
diff -u -r1.17 nfs_socket.c
--- nfs_socket.c	1996/07/11 16:32:45	1.17
+++ nfs_socket.c	1996/10/10 10:56:48
@@ -681,15 +681,17 @@
 		 * sbwait() after someone else has received my reply for me.
 		 * Also necessary for connection based protocols to avoid
 		 * race conditions during a reconnect.
+		 * If nfs_rcvlock() returns EALREADY, that means that
+		 * the reply has already been recieved by another
+		 * process and we can return immediately.  In this
+		 * case, the lock is not taken to avoid races with
+		 * other processes.
 		 */
 		error = nfs_rcvlock(myrep);
+		if (error == EALREADY)
+			return (0);
 		if (error)
 			return (error);
-		/* Already received, bye bye */
-		if (myrep->r_mrep != NULL) {
-			nfs_rcvunlock(&nmp->nm_flag);
-			return (0);
-		}
 		/*
 		 * Get the next Rpc reply off the socket
 		 */
@@ -1494,6 +1496,14 @@
 		*flagp |= NFSMNT_WANTRCV;
 		(void) tsleep((caddr_t)flagp, slpflag | (PZERO - 1), "nfsrcvlk",
 			slptimeo);
+		/*
+		 * If our reply was recieved while we were sleeping,
+		 * then just return without taking the lock to avoid a
+		 * situation where a single iod could 'capture' the
+		 * recieve lock.
+		 */
+		if (rep->r_mrep != NULL)
+			return (EALREADY);
 		if (slpflag == PCATCH) {
 			slpflag = 0;
 			slptimeo = 2 * hz;


--
Doug Rabson, Microsoft RenderMorphics Ltd.	Mail:  dfr@render.com
						Phone: +44 171 734 3761
						FAX:   +44 171 734 6426




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.961010131427.10204p-100000>