- Don't allow calls to vn_lock() with no lock type requested. Callers
which simply want a reference should use vref(). Callers which want to check validity need to hold a lock while performing any action based on that validity. vn_lock() would always release the interlock before returning making any action synchronous with the validity check impossible.
This commit is contained in:
parent
069c6953a0
commit
5634d48667
@ -854,26 +854,16 @@ vn_poll(fp, events, active_cred, td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that the vnode is still valid, and if so
|
* Acquire the requested lock and then check for validity. LK_RETRY
|
||||||
* acquire requested lock.
|
* permits vn_lock to return doomed vnodes.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_vn_lock(struct vnode *vp, int flags, char *file, int line)
|
_vn_lock(struct vnode *vp, int flags, char *file, int line)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
|
||||||
* With no lock type requested we're just polling for validity.
|
("vn_lock called with no locktype."));
|
||||||
*/
|
|
||||||
if ((flags & LK_TYPE_MASK) == 0) {
|
|
||||||
error = 0;
|
|
||||||
if ((flags & LK_INTERLOCK) == 0)
|
|
||||||
VI_LOCK(vp);
|
|
||||||
if (vp->v_iflag & VI_DOOMED)
|
|
||||||
error = ENOENT;
|
|
||||||
VI_UNLOCK(vp);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
do {
|
do {
|
||||||
error = VOP_LOCK1(vp, flags, file, line);
|
error = VOP_LOCK1(vp, flags, file, line);
|
||||||
flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */
|
flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user