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
This commit is contained in:
Konstantin Belousov 2009-06-25 18:54:56 +00:00
parent 9f80ce043d
commit 28fe6a3f3e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=194993

View File

@ -1937,9 +1937,14 @@ lf_iteratelocks_vnode(struct vnode *vp, lf_iterator *fn, void *arg)
* 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, lf_iterator *fn, void *arg)
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