- Make vn_lock() vget() and VOP_LOCK() all behave the same way WRT

LK_INTERLOCK.  The interlock will never be held on return from these
   functions even when there is an error.  Errors typically only occur when
   the XLOCK is held which means this isn't the vnode we want anyway.  Almost
   all users of these interfaces expected this behavior even though it was
   not provided before.
This commit is contained in:
Jeff Roberson 2002-08-22 07:44:45 +00:00
parent 510939d089
commit 9abf54f032
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102255
2 changed files with 9 additions and 18 deletions

View File

@ -739,10 +739,9 @@ vcanrecycle(struct vnode *vp)
/* We should be able to immediately acquire this */
/* XXX This looks like it should panic if it fails */
if (vn_lock(vp, LK_INTERLOCK | LK_EXCLUSIVE, td) != 0) {
VI_UNLOCK(vp);
if (vn_lock(vp, LK_INTERLOCK | LK_EXCLUSIVE, td) != 0)
return (EWOULDBLOCK);
}
/*
* Don't recycle if we still have cached pages.
*/
@ -1917,18 +1916,11 @@ vget(vp, flags, td)
*/
if ((flags & LK_INTERLOCK) == 0)
VI_LOCK(vp);
if (vp->v_iflag & VI_XLOCK) {
if (vp->v_vxproc == curthread) {
#if 0
/* this can now occur in normal operation */
log(LOG_INFO, "VXLOCK interlock avoided\n");
#endif
} else {
vp->v_iflag |= VI_XWANT;
msleep(vp, VI_MTX(vp), PINOD | PDROP, "vget", 0);
mp_fixme("interlock not released.");
return (ENOENT);
}
if (vp->v_iflag & VI_XLOCK && vp->v_vxproc != curthread) {
vp->v_iflag |= VI_XWANT;
msleep(vp, VI_MTX(vp), PINOD | PDROP, "vget", 0);
VI_UNLOCK(vp);
return (ENOENT);
}
vp->v_usecount++;

View File

@ -853,10 +853,9 @@ debug_vn_lock(vp, flags, td, filename, line)
msleep(vp, VI_MTX(vp), PINOD | PDROP,
"vn_lock", 0);
/*
* Since we're just going to return, unlock interlock
* if the caller didn't call us with it held.
* Since we're just going to return, unlock interlock.
*/
if ((flags & (LK_INTERLOCK|LK_RETRY)) == 0)
if ((flags & LK_RETRY) == 0)
VI_UNLOCK(vp);
error = ENOENT;
} else {