summaryrefslogtreecommitdiff
path: root/sys/nfs
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-05-19 16:36:05 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-05-19 16:36:05 +0000
commit0dd18224e71fc113ad576bbb090f81bc23f30712 (patch)
tree5b01f16dcb3d59ba11fdda15a01047557ad06526 /sys/nfs
parentfc8845fcb413005968a6519d665a10233ec08348 (diff)
from tsarna@netbsd.org (sysctl changes to come later):
Death to nfsiod! It is replaced by kernel threads that do the same thing. The number of kernel threads used is set with the vfs.nfs.iothreads sysctl.
Diffstat (limited to 'sys/nfs')
-rw-r--r--sys/nfs/nfs.h12
-rw-r--r--sys/nfs/nfs_syscalls.c56
-rw-r--r--sys/nfs/nfs_var.h4
-rw-r--r--sys/nfs/nfs_vfsops.c19
4 files changed, 78 insertions, 13 deletions
diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h
index 06c01af9b99..31e7a5b768b 100644
--- a/sys/nfs/nfs.h
+++ b/sys/nfs/nfs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs.h,v 1.7 1998/05/25 09:12:26 deraadt Exp $ */
+/* $OpenBSD: nfs.h,v 1.8 2000/05/19 16:36:03 mickey Exp $ */
/* $NetBSD: nfs.h,v 1.10.4.1 1996/05/27 11:23:56 fvdl Exp $ */
/*
@@ -237,11 +237,13 @@ struct nfsstats {
/*
* fs.nfs sysctl(3) identifiers
*/
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
+#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
+#define NFS_NIOTHREADS 2 /* number of i/o threads */
#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
+ { 0, 0 }, \
+ { "nfsstats", CTLTYPE_STRUCT }, \
+ { "niothreads", CTLTYPE_INT } \
}
/*
@@ -253,6 +255,7 @@ struct nfsstats {
* by them and break.
*/
#ifdef _KERNEL
+extern int nfs_niothreads;
struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
@@ -468,5 +471,4 @@ int nfsd_head_flag;
sizeof (struct ucred)))
#endif /* _KERNEL */
-
#endif /* _NFS_NFS_H */
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index c092d8cb684..4c09245f4fb 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.13 2000/02/07 04:47:53 assar Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.14 2000/05/19 16:36:03 mickey Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -58,6 +58,8 @@
#include <sys/namei.h>
#include <sys/syslog.h>
#include <sys/filedesc.h>
+#include <sys/signalvar.h>
+#include <sys/kthread.h>
#include <sys/syscallargs.h>
@@ -105,7 +107,8 @@ static struct nfsdrt nfsdrt;
#define FALSE 0
#ifdef NFSCLIENT
-static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
+struct proc *nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
+int nfs_niothreads = -1;
#endif
#ifdef NFSSERVER
@@ -839,7 +842,7 @@ nfsd_rt(sotype, nd, cacherep)
#ifdef NFSCLIENT
/*
- * Asynchronous I/O daemons for client nfs.
+ * Asynchronous I/O threads for client nfs.
* They do read-ahead and write-behind operations on the block I/O cache.
* Never returns unless it fails or gets killed.
*/
@@ -857,14 +860,15 @@ nfssvc_iod(p)
*/
myiod = -1;
for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
- if (nfs_asyncdaemon[i] == 0) {
- nfs_asyncdaemon[i]++;
+ if (nfs_asyncdaemon[i] == NULL) {
myiod = i;
break;
}
if (myiod == -1)
return (EBUSY);
+ nfs_asyncdaemon[myiod] = p;
nfs_numasync++;
+ p->p_holdcnt++;
/*
* Just loop around doin our stuff until SIGKILL
*/
@@ -912,13 +916,53 @@ nfssvc_iod(p)
} while ((bp = nbp) != NULL);
}
if (error) {
- nfs_asyncdaemon[myiod] = 0;
+ nfs_asyncdaemon[myiod] = NULL;
nfs_numasync--;
return (error);
}
}
}
+void
+start_nfsio(arg)
+ void *arg;
+{
+ nfssvc_iod(curproc);
+
+ kthread_exit(0);
+}
+
+void
+nfs_getset_niothreads(set)
+ int set;
+{
+ int i, have, start;
+
+ for (have = 0, i = 0; i < NFS_MAXASYNCDAEMON; i++)
+ if (nfs_asyncdaemon[i] != NULL)
+ have++;
+
+ if (set) {
+ /* clamp to sane range */
+ nfs_niothreads = max(0, min(nfs_niothreads, NFS_MAXASYNCDAEMON));
+
+ start = nfs_niothreads - have;
+
+ while (start > 0) {
+ kthread_create(start_nfsio, NULL, NULL, "nfsio");
+ start--;
+ }
+
+ for (i = 0; (start < 0) && (i < NFS_MAXASYNCDAEMON); i++)
+ if (nfs_asyncdaemon[i] != NULL) {
+ psignal(nfs_asyncdaemon[i], SIGKILL);
+ start++;
+ }
+ } else {
+ if (nfs_niothreads >= 0)
+ nfs_niothreads = have;
+ }
+}
/*
* Get an authorization string for the uid by having the mount_nfs sitting
diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h
index bd2ae3658e2..51b1bbbfc5d 100644
--- a/sys/nfs/nfs_var.h
+++ b/sys/nfs/nfs_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_var.h,v 1.10 2000/02/07 04:48:42 assar Exp $ */
+/* $OpenBSD: nfs_var.h,v 1.11 2000/05/19 16:36:03 mickey Exp $ */
/* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */
/*
@@ -305,6 +305,8 @@ void nfsrv_zapsock __P((struct nfssvc_sock *));
void nfsrv_slpderef __P((struct nfssvc_sock *));
void nfsrv_init __P((int));
int nfssvc_iod __P((struct proc *));
+void start_nfsio __P((void *));
+void nfs_getset_niothreads __P((int));
int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
char **, int *, char *, int *, NFSKERBKEY_T));
int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, int *,
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index 4b24082186e..9b4ce097747 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vfsops.c,v 1.30 2000/02/07 04:57:17 assar Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.31 2000/05/19 16:36:04 mickey Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
@@ -53,6 +53,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/systm.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -628,6 +629,12 @@ nfs_mount(mp, path, data, ndp, p)
return (EPROGMISMATCH);
if (error)
return (error);
+
+ if (nfs_niothreads < 0) {
+ nfs_niothreads = 4;
+ nfs_getset_niothreads(TRUE);
+ }
+
if (mp->mnt_flag & MNT_UPDATE) {
register struct nfsmount *nmp = VFSTONFS(mp);
@@ -960,6 +967,15 @@ nfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
}
return 0;
+ case NFS_NIOTHREADS:
+ nfs_getset_niothreads(0);
+
+ rv = sysctl_int(oldp, oldlenp, newp, newlen, &nfs_niothreads);
+ if (newp)
+ nfs_getset_niothreads(1);
+
+ return rv;
+
default:
return EOPNOTSUPP;
}
@@ -1036,3 +1052,4 @@ nfs_checkexp(mp, nam, exflagsp, credanonp)
{
return (EOPNOTSUPP);
}
+