Detect that a vnode has been reclaimed while vflush() was waiting to lock

the vnode and restart the loop.  Vflush() is vulnerable since it does not
hold a reference to the vnode and it holds no other locks while waiting
for the vnode lock.  The vnode will no longer be on the list when the
loop is restarted.

Approved by:	re (rwatson)
This commit is contained in:
Don Lewis 2003-05-16 19:46:51 +00:00
parent 5f616912b4
commit 1e9bc9f889

View File

@ -2397,6 +2397,17 @@ vflush(mp, rootrefs, flags)
VI_LOCK(vp);
mtx_unlock(&mntvnode_mtx);
vn_lock(vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY, td);
/*
* This vnode could have been reclaimed while we were
* waiting for the lock since we are not holding a
* reference.
* Start over if the vnode was reclaimed.
*/
if (vp->v_mount != mp) {
VOP_UNLOCK(vp, 0, td);
mtx_lock(&mntvnode_mtx);
goto loop;
}
/*
* Skip over a vnodes marked VV_SYSTEM.
*/