use condvar.

This commit is contained in:
yamt 2007-04-29 14:56:59 +00:00
parent aca6764004
commit bbe5115ad9
3 changed files with 21 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_socket.c,v 1.150 2007/04/29 10:30:18 yamt Exp $ */
/* $NetBSD: nfs_socket.c,v 1.151 2007/04/29 14:56:59 yamt Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.150 2007/04/29 10:30:18 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.151 2007/04/29 14:56:59 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -414,14 +414,13 @@ nfs_disconnect(nmp)
* wait for them to go away unhappy, to prevent *nmp
* from evaporating while they're sleeping.
*/
mutex_enter(&nmp->nm_lock);
while (nmp->nm_waiters > 0) {
mutex_enter(&nmp->nm_lock);
cv_broadcast(&nmp->nm_rcvcv);
cv_broadcast(&nmp->nm_sndcv);
mutex_exit(&nmp->nm_lock);
(void) tsleep(&nmp->nm_waiters, PVFS,
"nfsdis", 0);
cv_wait(&nmp->nm_disconcv, &nmp->nm_lock);
}
mutex_exit(&nmp->nm_lock);
}
soclose(so);
}
@ -812,20 +811,27 @@ nfs_reply(myrep, lwp)
/*
* Get the next Rpc reply off the socket
*/
mutex_enter(&nmp->nm_lock);
nmp->nm_waiters++;
mutex_exit(&nmp->nm_lock);
error = nfs_receive(myrep, &nam, &mrep, lwp);
nfs_rcvunlock(nmp);
mutex_enter(&nmp->nm_lock);
nmp->nm_waiters--;
cv_signal(&nmp->nm_disconcv);
mutex_exit(&nmp->nm_lock);
if (error) {
if (nmp->nm_iflag & NFSMNT_DISMNT) {
/*
* Oops, we're going away now..
*/
nmp->nm_waiters--;
wakeup (&nmp->nm_waiters);
return error;
}
nmp->nm_waiters--;
/*
* Ignore routing errors on connectionless protocols? ?
*/
@ -840,7 +846,6 @@ nfs_reply(myrep, lwp)
}
return (error);
}
nmp->nm_waiters--;
if (nam)
m_freem(nam);
@ -1825,7 +1830,7 @@ nfs_rcvlock(struct nfsmount *nmp, struct nfsreq *rep)
slptimeo);
}
if (*flagp & NFSMNT_DISMNT) {
wakeup(&nmp->nm_waiters);
cv_signal(&nmp->nm_disconcv);
error = EIO;
goto quit;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vfsops.c,v 1.175 2007/04/29 10:30:19 yamt Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.176 2007/04/29 14:57:00 yamt Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.175 2007/04/29 10:30:19 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.176 2007/04/29 14:57:00 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -728,6 +728,7 @@ mountnfs(argp, mp, nam, pth, hst, vpp, l)
cv_init(&nmp->nm_rcvcv, "nfsrcv");
cv_init(&nmp->nm_sndcv, "nfssnd");
cv_init(&nmp->nm_aiocv, "nfsaio");
cv_init(&nmp->nm_disconcv, "nfsdis");
}
vfs_getnewfsid(mp);
nmp->nm_mountp = mp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsmount.h,v 1.43 2007/04/29 10:30:19 yamt Exp $ */
/* $NetBSD: nfsmount.h,v 1.44 2007/04/29 14:57:00 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -170,6 +170,7 @@ struct nfsmount {
u_int64_t nm_maxfilesize; /* maximum file size */
int nm_iflag; /* internal flags */
int nm_waiters; /* number of waiting listeners.. */
kcondvar_t nm_disconcv;
long nm_wcckludgetime; /* see nfs_check_wccdata() */
struct io_stats *nm_stats; /* per nfs mount statistics */
};