From bg@bg.sics.se  Tue Apr  3 11:59:21 2001
Return-Path: <bg@bg.sics.se>
Received: from bg.sics.se (bg.sics.se [193.10.66.124])
	by hub.freebsd.org (Postfix) with ESMTP id 394E637B71D
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  3 Apr 2001 11:59:20 -0700 (PDT)
	(envelope-from bg@bg.sics.se)
Received: (from bg@localhost)
	by bg.sics.se (8.11.1/8.11.1) id f33IxKm19862;
	Tue, 3 Apr 2001 20:59:20 +0200 (CEST)
	(envelope-from bg)
Message-Id: <200104031859.f33IxKm19862@bg.sics.se>
Date: Tue, 3 Apr 2001 20:59:20 +0200 (CEST)
From: bg@sics.se
Reply-To: bg@sics.se
To: FreeBSD-gnats-submit@freebsd.org
Cc: bg@sics.se
Subject: Slow NFS TCP mounts
X-Send-Pr-Version: 3.2

>Number:         26324
>Category:       kern
>Synopsis:       Defaults for NFS mounts over TCP are slow
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 03 12:00:03 PDT 2001
>Closed-Date:    Sat Jan 31 02:42:56 PST 2004
>Last-Modified:  Sat Jan 31 02:42:56 PST 2004
>Originator:     Bjoern Groenvall
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
SICS
>Environment:

FreeBSD NFS clients.

>Description:

Defaults for NFSv3 mounts over TCP limits rsize and wsize to
8kbytes. This is unnecessarily conservative and leads to slow
NFS read/write performance.

NFSv3 has a mechanism to negotiate these parameters so there is no
danger in increasing the defaults to something more appropiate (e.g
sun defaults to 32kbytes).

>How-To-Repeat:
>Fix:

The following patch increases NFS read and write performance between
two FreeBSD machines to ~80Mbytes/s. This was measured over an idle
100Mbit/s network.

Patch was tested on a FreeBSD 4.2-RELEASE machine.

--- /sys/nfs/nfs_vfsops.c.ORIG	Sun Sep 10 03:45:36 2000
+++ /sys/nfs/nfs_vfsops.c	Mon Apr  2 14:13:35 2001
@@ -841,7 +841,6 @@
 	register struct nfsmount *nmp;
 	struct nfsnode *np;
 	int error;
-	struct vattr attrs;
 
 	if (mp->mnt_flag & MNT_UPDATE) {
 		nmp = VFSTONFS(mp);
@@ -883,8 +882,17 @@
 
 	nmp->nm_timeo = NFS_TIMEO;
 	nmp->nm_retry = NFS_RETRANS;
-	nmp->nm_wsize = NFS_WSIZE;
-	nmp->nm_rsize = NFS_RSIZE;
+	if (argp->flags & NFSMNT_NFSV3) {
+		if (argp->sotype == SOCK_STREAM) {
+			nmp->nm_wsize = nmp->nm_rsize = NFS_MAXDATA;
+		} else {
+			nmp->nm_wsize = NFS_WSIZE;
+			nmp->nm_rsize = NFS_RSIZE;
+		}
+	} else {
+		nmp->nm_wsize = NFS_WSIZE;
+		nmp->nm_rsize = NFS_RSIZE;
+	}
 	nmp->nm_readdirsize = NFS_READDIRSIZE;
 	nmp->nm_numgrps = NFS_MAXGRPS;
 	nmp->nm_readahead = NFS_DEFRAHEAD;
@@ -932,10 +940,15 @@
 	*vpp = NFSTOV(np);
 
 	/*
-	 * Get file attributes for the mountpoint.  This has the side
-	 * effect of filling in (*vpp)->v_type with the correct value.
+	 * Retrieval of mountpoint attributes is delayed until nfs_root
+	 * or nfs_statfs are first called. This will happen either when
+	 * we first traverse the mount point or if somebody does a df.
+	 *
+	 * NFSSTA_GOTFSINFO is used to flag if we have succesfully
+	 * retreived mountpoint attributes. In the case of NFSv3 we
+	 * also flag static fsinfo.
 	 */
-	VOP_GETATTR(*vpp, &attrs, curproc->p_ucred, curproc);
+	(*vpp)->v_type = VNON;
 
 	/*
 	 * Lose the lock but keep the ref.
@@ -1042,6 +1055,20 @@
 	if (error)
 		return (error);
 	vp = NFSTOV(np);
+	/*
+	 * Get transfer parameters and root vnode attributes.
+	 */
+	if ((nmp->nm_state & NFSSTA_GOTFSINFO) == 0) {
+	    if (nmp->nm_flag & NFSMNT_NFSV3) {
+	        nfs_fsinfo(nmp, vp, curproc->p_ucred, curproc);
+		mp->mnt_stat.f_iosize = nfs_iosize(nmp);
+	    } else {
+	        struct vattr attrs;
+	        error = VOP_GETATTR(vp, &attrs, curproc->p_ucred, curproc);
+		if (!error)
+		    nmp->nm_state |= NFSSTA_GOTFSINFO;		  
+	  }
+	}
 	if (vp->v_type == VNON)
 	    vp->v_type = VDIR;
 	vp->v_flag = VROOT;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dillon 
Responsible-Changed-By: silby 
Responsible-Changed-When: Tue Jan 8 18:01:28 PST 2002 
Responsible-Changed-Why:  
Over to Mr.NFS, Dillon. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=26324 
Responsible-Changed-From-To: dillon->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sat Feb 22 18:15:47 PST 2003 
Responsible-Changed-Why:  
Back to the free pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26324 
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Sat Jan 31 02:42:43 PST 2004 
State-Changed-Why:  
PR kern/62024 was committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26324 
>Unformatted:
