From 0160dedc65d5fdd8ef1ccaad50d1f819b6141a78 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Sat, 10 May 1997 16:59:36 +0000 Subject: [PATCH] Implement a separate control for write gathering on NFSv3. This is turned off for NFSv3 by default since write gathering seems to reduce performance for NFSv3 by up to 60%. Add sysctl knobs to control both variables. --- sys/nfs/nfs_serv.c | 6 ++++-- sys/nfs/nfs_syscalls.c | 12 ++++++++++-- sys/nfsclient/nfs_nfsiod.c | 12 ++++++++++-- sys/nfsserver/nfs_serv.c | 6 ++++-- sys/nfsserver/nfs_syscalls.c | 12 ++++++++++-- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c index 7946328e1b13..75842dcb3e9f 100644 --- a/sys/nfs/nfs_serv.c +++ b/sys/nfs/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 - * $Id: nfs_serv.c,v 1.40 1997/03/29 12:40:18 bde Exp $ + * $Id: nfs_serv.c,v 1.41 1997/05/10 16:12:03 dfr Exp $ */ /* @@ -96,6 +96,7 @@ extern enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; +int nfsrvw_procrastinate_v3 = 0; int nfs_async; SYSCTL_INT(_vfs_nfs, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0, ""); @@ -929,7 +930,8 @@ nfsrv_writegather(ndp, slp, procp, mrq) nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; - nfsd->nd_time = cur_usec + nfsrvw_procrastinate; + nfsd->nd_time = cur_usec + + (v3 ? nfsrvw_procrastinate_v3 : nfsrvw_procrastinate); /* * Now, get the write header.. diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index ea35c01b8262..83cfa9542c19 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_syscalls.c,v 1.21 1997/04/27 20:01:23 wollman Exp $ + * $Id: nfs_syscalls.c,v 1.22 1997/04/30 09:51:37 dfr Exp $ */ #include @@ -86,6 +86,7 @@ extern int nqsrv_writeslack; extern int nfsrtton; extern struct nfsstats nfsstats; extern int nfsrvw_procrastinate; +extern int nfsrvw_procrastinate_v3; struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock; static int nuidhash_max = NFS_MAXUIDHASH; @@ -111,6 +112,8 @@ static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, ""); /* * NFS server system calls @@ -456,6 +459,7 @@ nfssvc_nfsd(nsd, argp, p) struct nfsrv_descript *nd = NULL; struct mbuf *mreq; int error = 0, cacherep, s, sotype, writes_todo; + int procrastinate; u_quad_t cur_usec; #ifndef nolint @@ -626,8 +630,12 @@ nfssvc_nfsd(nsd, argp, p) do { switch (cacherep) { case RC_DOIT: + if (nd && (nd->nd_flag & ND_NFSV3)) + procrastinate = nfsrvw_procrastinate_v3; + else + procrastinate = nfsrvw_procrastinate; if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && - nfsrvw_procrastinate > 0 && !notstarted)) + procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, nfsd->nfsd_procp, &mreq); else diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index ea35c01b8262..83cfa9542c19 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_syscalls.c,v 1.21 1997/04/27 20:01:23 wollman Exp $ + * $Id: nfs_syscalls.c,v 1.22 1997/04/30 09:51:37 dfr Exp $ */ #include @@ -86,6 +86,7 @@ extern int nqsrv_writeslack; extern int nfsrtton; extern struct nfsstats nfsstats; extern int nfsrvw_procrastinate; +extern int nfsrvw_procrastinate_v3; struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock; static int nuidhash_max = NFS_MAXUIDHASH; @@ -111,6 +112,8 @@ static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, ""); /* * NFS server system calls @@ -456,6 +459,7 @@ nfssvc_nfsd(nsd, argp, p) struct nfsrv_descript *nd = NULL; struct mbuf *mreq; int error = 0, cacherep, s, sotype, writes_todo; + int procrastinate; u_quad_t cur_usec; #ifndef nolint @@ -626,8 +630,12 @@ nfssvc_nfsd(nsd, argp, p) do { switch (cacherep) { case RC_DOIT: + if (nd && (nd->nd_flag & ND_NFSV3)) + procrastinate = nfsrvw_procrastinate_v3; + else + procrastinate = nfsrvw_procrastinate; if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && - nfsrvw_procrastinate > 0 && !notstarted)) + procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, nfsd->nfsd_procp, &mreq); else diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 7946328e1b13..75842dcb3e9f 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 - * $Id: nfs_serv.c,v 1.40 1997/03/29 12:40:18 bde Exp $ + * $Id: nfs_serv.c,v 1.41 1997/05/10 16:12:03 dfr Exp $ */ /* @@ -96,6 +96,7 @@ extern enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; +int nfsrvw_procrastinate_v3 = 0; int nfs_async; SYSCTL_INT(_vfs_nfs, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0, ""); @@ -929,7 +930,8 @@ nfsrv_writegather(ndp, slp, procp, mrq) nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; - nfsd->nd_time = cur_usec + nfsrvw_procrastinate; + nfsd->nd_time = cur_usec + + (v3 ? nfsrvw_procrastinate_v3 : nfsrvw_procrastinate); /* * Now, get the write header.. diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index ea35c01b8262..83cfa9542c19 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_syscalls.c,v 1.21 1997/04/27 20:01:23 wollman Exp $ + * $Id: nfs_syscalls.c,v 1.22 1997/04/30 09:51:37 dfr Exp $ */ #include @@ -86,6 +86,7 @@ extern int nqsrv_writeslack; extern int nfsrtton; extern struct nfsstats nfsstats; extern int nfsrvw_procrastinate; +extern int nfsrvw_procrastinate_v3; struct nfssvc_sock *nfs_udpsock, *nfs_cltpsock; static int nuidhash_max = NFS_MAXUIDHASH; @@ -111,6 +112,8 @@ static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); static int nfs_privport = 0; SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, ""); /* * NFS server system calls @@ -456,6 +459,7 @@ nfssvc_nfsd(nsd, argp, p) struct nfsrv_descript *nd = NULL; struct mbuf *mreq; int error = 0, cacherep, s, sotype, writes_todo; + int procrastinate; u_quad_t cur_usec; #ifndef nolint @@ -626,8 +630,12 @@ nfssvc_nfsd(nsd, argp, p) do { switch (cacherep) { case RC_DOIT: + if (nd && (nd->nd_flag & ND_NFSV3)) + procrastinate = nfsrvw_procrastinate_v3; + else + procrastinate = nfsrvw_procrastinate; if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE && - nfsrvw_procrastinate > 0 && !notstarted)) + procrastinate > 0 && !notstarted)) error = nfsrv_writegather(&nd, slp, nfsd->nfsd_procp, &mreq); else