summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2007-04-19 14:46:45 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2007-04-19 14:46:45 +0000
commite07f8448e8302bc12a15f5339806aeda44830d6c (patch)
treeef75588da3494e8972383dc5d61cf3768308c8af /sys
parente597d17a58cadd3c3ef1cf84746578b165d0eeaa (diff)
Replace the nfskevq_lock lockmgr lock with rwlock.
Replace nfs_kqinit() wich just calls lockinit with RWLOCK_INITALIZER. Assorted cleanup. ok tedu@ "reads good" art@
Diffstat (limited to 'sys')
-rw-r--r--sys/nfs/nfs_kq.c36
-rw-r--r--sys/nfs/nfs_subs.c6
-rw-r--r--sys/nfs/nfs_var.h3
3 files changed, 17 insertions, 28 deletions
diff --git a/sys/nfs/nfs_kq.c b/sys/nfs/nfs_kq.c
index 6a02b57b529..23e72b4576a 100644
--- a/sys/nfs/nfs_kq.c
+++ b/sys/nfs/nfs_kq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_kq.c,v 1.3 2007/04/12 18:21:19 thib Exp $ */
+/* $OpenBSD: nfs_kq.c,v 1.4 2007/04/19 14:46:44 thib Exp $ */
/* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */
/*-
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $");
#include <sys/unistd.h>
#include <sys/file.h>
#include <sys/kthread.h>
+#include <sys/rwlock.h>
#include <uvm/uvm_extern.h>
#include <uvm/uvm.h>
@@ -75,16 +76,10 @@ struct kevq {
};
SLIST_HEAD(kevqlist, kevq);
-static struct lock nfskevq_lock;
+struct rwlock nfskevq_lock = RWLOCK_INITIALIZER;
static struct proc *pnfskq;
static struct kevqlist kevlist = SLIST_HEAD_INITIALIZER(kevlist);
-void
-nfs_kqinit(void)
-{
- lockinit(&nfskevq_lock, PSOCK, "nfskqlck", 0, 0);
-}
-
/*
* This quite simplistic routine periodically checks for server changes
* of any of the watched files every NFS_MINATTRTIMO/2 seconds.
@@ -110,7 +105,7 @@ nfs_kqpoll(void *arg)
int error;
for(;;) {
- lockmgr(&nfskevq_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&nfskevq_lock);
SLIST_FOREACH(ke, &kevlist, kev_link) {
struct nfsnode *np = VTONFS(ke->vp);
@@ -127,7 +122,7 @@ nfs_kqpoll(void *arg)
* for changes.
*/
ke->flags |= KEVQ_BUSY;
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
+ rw_exit_write(&nfskevq_lock);
/* save v_size, nfs_getattr() updates it */
osize = np->n_size;
@@ -164,7 +159,7 @@ nfs_kqpoll(void *arg)
}
next:
- lockmgr(&nfskevq_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&nfskevq_lock);
ke->flags &= ~KEVQ_BUSY;
if (ke->flags & KEVQ_WANT) {
ke->flags &= ~KEVQ_WANT;
@@ -175,10 +170,10 @@ next:
if (SLIST_EMPTY(&kevlist)) {
/* Nothing more to watch, exit */
pnfskq = NULL;
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
+ rw_exit_write(&nfskevq_lock);
kthread_exit(0);
}
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
+ rw_exit_write(&nfskevq_lock);
/* wait a while before checking for changes again */
tsleep(pnfskq, PSOCK, "nfskqpw",
@@ -204,14 +199,14 @@ filt_nfsdetach(struct knote *kn)
simple_unlock(&vp->v_selectinfo.vsi_lock);
/* Remove the vnode from watch list */
- lockmgr(&nfskevq_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&nfskevq_lock);
SLIST_FOREACH(ke, &kevlist, kev_link) {
if (ke->vp == vp) {
while (ke->flags & KEVQ_BUSY) {
ke->flags |= KEVQ_WANT;
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
+ rw_exit_write(&nfskevq_lock);
(void) tsleep(ke, PSOCK, "nfskqdet", 0);
- lockmgr(&nfskevq_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&nfskevq_lock);
}
if (ke->usecount > 1) {
@@ -225,7 +220,7 @@ filt_nfsdetach(struct knote *kn)
break;
}
}
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
+ rw_exit_write(&nfskevq_lock);
}
static int
@@ -316,7 +311,7 @@ nfs_kqfilter(void *v)
memset(&attr, 0, sizeof(attr));
(void) VOP_GETATTR(vp, &attr, p->p_ucred, p);
- lockmgr(&nfskevq_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&nfskevq_lock);
/* ensure the poller is running */
if (!pnfskq) {
@@ -358,8 +353,7 @@ nfs_kqfilter(void *v)
SLIST_INSERT_HEAD(&vp->v_klist, kn, kn_selnext);
#endif
- out:
- lockmgr(&nfskevq_lock, LK_RELEASE, NULL);
-
+out:
+ rw_exit_write(&nfskevq_lock);
return (error);
}
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index 7585b97a8da..ae497c69a62 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.60 2007/04/13 10:01:35 thib Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.61 2007/04/19 14:46:44 thib Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -1070,10 +1070,6 @@ nfs_init()
timeout_set(&nfs_timer_to, nfs_timer, &nfs_timer_to);
nfs_timer(&nfs_timer_to);
-
-#ifdef NFSCLIENT
- nfs_kqinit();
-#endif
}
#ifdef NFSCLIENT
diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h
index 5e2e85b3d49..9680562d095 100644
--- a/sys/nfs/nfs_var.h
+++ b/sys/nfs/nfs_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_var.h,v 1.25 2007/04/13 17:09:22 thib Exp $ */
+/* $OpenBSD: nfs_var.h,v 1.26 2007/04/19 14:46:44 thib Exp $ */
/* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */
/*
@@ -286,5 +286,4 @@ int nfs_savenickauth(struct nfsmount *, struct ucred *, int, NFSKERBKEY_T,
/* nfs_kq.c */
int nfs_kqfilter(void *);
-void nfs_kqinit(void);