- fix decreasing of vfs.nfs.iothreads after the recent partial merge

of vmlocking.
- don't make nfsiod exit with requests left.
- make NFSSVC_BIOD a dummy so that nfsiod can be simplified.
This commit is contained in:
yamt 2007-07-20 15:36:41 +00:00
parent f228decd49
commit 97c7bbe6b8
4 changed files with 46 additions and 59 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_bio.c,v 1.160 2007/07/17 10:24:10 yamt Exp $ */
/* $NetBSD: nfs_bio.c,v 1.161 2007/07/20 15:36:41 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.160 2007/07/17 10:24:10 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.161 2007/07/20 15:36:41 yamt Exp $");
#include "opt_nfs.h"
#include "opt_ddb.h"
@ -768,7 +768,7 @@ again:
* Found one, so wake it up and tell it which
* mount to process.
*/
iod->nid_want = NULL;
iod->nid_want = false;
iod->nid_mount = nmp;
cv_signal(&iod->nid_cv);
mutex_enter(&nmp->nm_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_syscalls.c,v 1.117 2007/07/09 21:11:31 ad Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.118 2007/07/20 15:36:42 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.117 2007/07/09 21:11:31 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.118 2007/07/20 15:36:42 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -178,7 +178,7 @@ sys_nfssvc(struct lwp *l, void *v, register_t *retval)
#endif
if (SCARG(uap, flag) & NFSSVC_BIOD) {
#if defined(NFS) && defined(COMPAT_14)
error = nfssvc_iod(l);
error = kpause("nfsbiod", true, 0, NULL); /* dummy impl */
#else
error = ENOSYS;
#endif
@ -1002,34 +1002,31 @@ int nfs_defect = 0;
* Never returns unless it fails or gets killed.
*/
int
nfssvc_iod(l)
struct lwp *l;
static void
nfssvc_iod(void *arg)
{
struct lwp *l = curlwp;
struct buf *bp;
int i;
struct nfs_iod *myiod;
struct nfsmount *nmp;
int error = 0;
struct proc *p = l->l_proc;
/*
* Assign my position or return error if too many already running
*/
myiod = NULL;
for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
if (nfs_asyncdaemon[i].nid_proc == NULL) {
if (nfs_asyncdaemon[i].nid_lwp == NULL) {
myiod = &nfs_asyncdaemon[i];
break;
}
if (myiod == NULL)
return (EBUSY);
myiod->nid_proc = p;
if (myiod == NULL) {
goto quit;
}
myiod->nid_lwp = l;
myiod->nid_exiting = false;
nfs_numasync++;
uvm_lwp_hold(l);
/*
* Just loop around doing our stuff until SIGKILL
*/
for (;;) {
mutex_enter(&myiod->nid_lock);
while (/*CONSTCOND*/ true) {
@ -1043,13 +1040,12 @@ nfssvc_iod(l)
nmp->nm_bufqiods--;
mutex_exit(&nmp->nm_lock);
}
myiod->nid_want = p;
myiod->nid_want = true;
myiod->nid_mount = NULL;
error = cv_wait_sig(&myiod->nid_cv, &myiod->nid_lock);
if (error) {
mutex_exit(&myiod->nid_lock);
if (myiod->nid_exiting) {
goto quit;
}
cv_wait(&myiod->nid_cv, &myiod->nid_lock);
}
while ((bp = TAILQ_FIRST(&nmp->nm_bufq)) != NULL) {
@ -1076,21 +1072,17 @@ nfssvc_iod(l)
mutex_exit(&nmp->nm_lock);
}
quit:
uvm_lwp_rele(l);
mutex_enter(&myiod->nid_lock);
nmp = myiod->nid_mount;
if (nmp) {
mutex_enter(&nmp->nm_lock);
nmp->nm_bufqiods--;
mutex_exit(&nmp->nm_lock);
if (myiod != NULL) {
KASSERT(mutex_owned(&myiod->nid_lock));
KASSERT(myiod->nid_mount == NULL);
myiod->nid_want = false;
myiod->nid_mount = NULL;
myiod->nid_lwp = NULL;
mutex_exit(&myiod->nid_lock);
nfs_numasync--;
}
myiod->nid_want = NULL;
myiod->nid_mount = NULL;
myiod->nid_proc = NULL;
mutex_exit(&myiod->nid_lock);
nfs_numasync--;
return error;
kthread_exit(0);
}
void
@ -1105,14 +1097,6 @@ nfs_iodinit()
}
}
void
start_nfsio(void *arg)
{
nfssvc_iod(curlwp);
kthread_exit(0);
}
void
nfs_getset_niothreads(set)
int set;
@ -1120,7 +1104,7 @@ nfs_getset_niothreads(set)
int i, have, start;
for (have = 0, i = 0; i < NFS_MAXASYNCDAEMON; i++)
if (nfs_asyncdaemon[i].nid_proc != NULL)
if (nfs_asyncdaemon[i].nid_lwp != NULL)
have++;
if (set) {
@ -1130,18 +1114,22 @@ nfs_getset_niothreads(set)
start = nfs_niothreads - have;
while (start > 0) {
kthread_create(PRI_NONE, 0, NULL, start_nfsio, NULL,
kthread_create(PRI_NONE, 0, NULL, nfssvc_iod, NULL,
NULL, "nfsio");
start--;
}
for (i = 0; (start < 0) && (i < NFS_MAXASYNCDAEMON); i++)
if (nfs_asyncdaemon[i].nid_proc != NULL) {
mutex_enter(&proclist_mutex);
psignal(nfs_asyncdaemon[i].nid_proc, SIGKILL);
mutex_exit(&proclist_mutex);
for (i = 0; (start < 0) && (i < NFS_MAXASYNCDAEMON); i++) {
struct nfs_iod *nid = &nfs_asyncdaemon[i];
if (nid->nid_lwp != NULL) {
mutex_enter(&nid->nid_lock);
nid->nid_exiting = true;
cv_signal(&nid->nid_cv);
mutex_exit(&nid->nid_lock);
start++;
}
}
} else {
if (nfs_niothreads >= 0)
nfs_niothreads = have;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_var.h,v 1.69 2007/07/12 19:35:35 dsl Exp $ */
/* $NetBSD: nfs_var.h,v 1.70 2007/07/20 15:36:42 yamt Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -284,9 +284,7 @@ int nfssvc_nfsd(struct nfsd_srvargs *, void *, struct lwp *);
void nfsrv_zapsock(struct nfssvc_sock *);
void nfsrv_slpderef(struct nfssvc_sock *);
void nfsrv_init(int);
int nfssvc_iod(struct lwp *);
void nfs_iodinit(void);
void start_nfsio(void *);
void nfs_getset_niothreads(int);
int nfs_getauth(struct nfsmount *, struct nfsreq *, kauth_cred_t, char **,
int *, char *, int *, NFSKERBKEY_T);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsnode.h,v 1.63 2007/04/29 14:58:21 yamt Exp $ */
/* $NetBSD: nfsnode.h,v 1.64 2007/07/20 15:36:42 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -213,19 +213,20 @@ LIST_HEAD(nfsnodehashhead, nfsnode);
#define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
#define NFSTOV(np) ((np)->n_vnode)
#ifdef _KERNEL
/*
* Per-nfsiod datas
*/
struct nfs_iod {
kmutex_t nid_lock;
kcondvar_t nid_cv;
struct proc *nid_proc;
struct proc *nid_want;
lwp_t *nid_lwp;
struct nfsmount *nid_mount;
bool nid_want;
bool nid_exiting;
};
#ifdef _KERNEL
extern struct nfs_iod nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
extern u_long nfsdirhashmask;