svn commit: r194993 - head/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Thu Jun 25 18:54:57 UTC 2009
Author: kib
Date: Thu Jun 25 18:54:56 2009
New Revision: 194993
URL: http://svn.freebsd.org/changeset/base/194993
Log:
In lf_iteratelocks_vnode, increment state->ls_threads around iterating
of the vnode advisory lock list. This prevents deallocation of state
while inside the loop.
Reported and tested by: pho
MFC after: 2 weeks
Modified:
head/sys/kern/kern_lockf.c
Modified: head/sys/kern/kern_lockf.c
==============================================================================
--- head/sys/kern/kern_lockf.c Thu Jun 25 18:51:35 2009 (r194992)
+++ head/sys/kern/kern_lockf.c Thu Jun 25 18:54:56 2009 (r194993)
@@ -1937,9 +1937,14 @@ lf_iteratelocks_vnode(struct vnode *vp,
* make sure it doesn't go away before we are finished.
*/
STAILQ_INIT(&locks);
+ VI_LOCK(vp);
ls = vp->v_lockf;
- if (!ls)
+ if (!ls) {
+ VI_UNLOCK(vp);
return (0);
+ }
+ ls->ls_threads++;
+ VI_UNLOCK(vp);
sx_xlock(&ls->ls_lock);
LIST_FOREACH(lf, &ls->ls_active, lf_link) {
@@ -1960,6 +1965,10 @@ lf_iteratelocks_vnode(struct vnode *vp,
STAILQ_INSERT_TAIL(&locks, ldesc, link);
}
sx_xunlock(&ls->ls_lock);
+ VI_LOCK(vp);
+ ls->ls_threads--;
+ wakeup(ls);
+ VI_UNLOCK(vp);
/*
* Call the iterator function for each lock in turn. If the
More information about the svn-src-all
mailing list