Subject: Re: Raising NFS parameters for higher bandwith or "long fat pipe"
To: None <tech-net@NetBSD.org>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: tech-net
Date: 12/06/2003 12:48:00
Darn, I forgot the kthread patch.  Here's a proof-of-concept version,
which just fires up a (constant) 20 nfsd kthreads when the master
first calls nfsvc(). With that glaring limitation, it works for me.



Index: nfs_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/nfs/nfs_syscalls.c,v
retrieving revision 1.70
diff -u -r1.70 nfs_syscalls.c
--- nfs_syscalls.c	2003/08/07 16:33:53	1.70
+++ nfs_syscalls.c	2003/12/06 20:27:03
@@ -130,6 +130,8 @@
 #ifdef NFSSERVER
 static void nfsd_rt __P((int, struct nfsrv_descript *, int));
 static struct nfssvc_sock *nfsrv_sockalloc __P((void));
+static void	init_nfsd __P((void *));
+static void	more_nfsds __P((int));
 #endif
 
 /*
@@ -170,6 +172,7 @@
 	struct nfsd *nfsd;
 	struct nfssvc_sock *slp;
 	struct nfsuid *nuidp;
+	static int done_threads = 0;
 #endif
 
 	/*
@@ -188,6 +191,11 @@
 	}
 	simple_unlock(&nfsd_slock);
 	splx(s);
+	if (done_threads == 0) {
+		done_threads = 1;
+		more_nfsds(20);
+	}
+	  
 #endif
 	if (SCARG(uap, flag) & NFSSVC_BIOD) {
 #if defined(NFS) && defined(COMPAT_14)
@@ -818,6 +826,34 @@
 		nfsrv_init(TRUE);	/* Reinitialize everything */
 	return (error);
 }
+
+
+#ifdef NFSSERVER
+/* 
+ * Create new nfsd kthread(s).
+ */
+void
+more_nfsds(int n)
+{
+	while (--n > 0)
+	     kthread_create1(init_nfsd, NULL, NULL, "nfsd");
+}
+
+
+/*
+ * Initial entrypoint for a newly-created nfsd kthread.
+ */
+void
+init_nfsd(void *arg)
+{
+	struct nfsd_srvargs *nsd;
+
+	nsd = malloc(sizeof (*nsd), M_NFSD, M_WAITOK|M_ZERO);
+	nfssvc_nfsd(nsd, NULL, curlwp);
+	free(nsd, M_NFSD);
+	kthread_exit(0);
+}
+#endif /* NFSSERVER */
 
 /*
  * Shut down a socket associated with an nfssvc_sock structure.