This patch fixes a locking bug that can result in deadlock if

the codepath is followed.

From the PR:

  vclean calls vrele leading to deadlock (if usecount > 0)

  vclean() calls vrele() if v_usecount of the node was higher than one.
  But before calling it, it sets the VXLOCK flag, which will make
  vn_lock called from vrele dead-lock.

PR:		kern/15117
Submitted by:	Assar Westerlund <assar@stacken.kth.se>
Reviewed by:	rwatson
Obtained from:	NetBSD
This commit is contained in:
Robert Watson 2000-01-29 15:22:58 +00:00
parent 8f8e587948
commit 9a2b8fca80
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56837
2 changed files with 34 additions and 4 deletions

View file

@ -1701,8 +1701,23 @@ vclean(vp, flags, p)
if (VOP_RECLAIM(vp, p))
panic("vclean: cannot reclaim");
if (active)
vrele(vp);
if (active) {
/*
* Inline copy of vrele() since VOP_INACTIVE
* has already been called.
*/
simple_lock(&vp->v_interlock);
if (--vp->v_usecount <= 0) {
#ifdef DIAGNOSTIC
if (vp->v_usecount < 0 || vp->v_writecount != 0) {
vprint("vclean: bad ref count", vp);
panic("vclean: ref cnt");
}
#endif
vfree(vp);
}
simple_unlock(&vp->v_interlock);
}
cache_purge(vp);
if (vp->v_vnlock) {

View file

@ -1701,8 +1701,23 @@ vclean(vp, flags, p)
if (VOP_RECLAIM(vp, p))
panic("vclean: cannot reclaim");
if (active)
vrele(vp);
if (active) {
/*
* Inline copy of vrele() since VOP_INACTIVE
* has already been called.
*/
simple_lock(&vp->v_interlock);
if (--vp->v_usecount <= 0) {
#ifdef DIAGNOSTIC
if (vp->v_usecount < 0 || vp->v_writecount != 0) {
vprint("vclean: bad ref count", vp);
panic("vclean: ref cnt");
}
#endif
vfree(vp);
}
simple_unlock(&vp->v_interlock);
}
cache_purge(vp);
if (vp->v_vnlock) {