FreeBSD/sys/kern/vfs_vnops.c
/*
 * Acquire the requested lock and then check for validity.  LK_RETRY
 * permits vn_lock to return doomed vnodes.
 */
Acquire the requested lock and then check for validity.  LK_RETRY
permits vn_lock to return doomed vnodes.
Acquire the requested lock and then check for validity . LK_RETRY permits vn_lock to return doomed vnodes .
int
_vn_lock(struct vnode *vp, int flags, char *file, int line)
{
	int error;
	VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
	    ("vn_lock called with no locktype."));
	do {
#ifdef DEBUG_VFS_LOCKS
		KASSERT(vp->v_holdcnt != 0,
		    ("vn_lock %p: zero hold count", vp));
#endif
		error = VOP_LOCK1(vp, flags, file, line);
		flags &= ~LK_INTERLOCK;	
		KASSERT((flags & LK_RETRY) == 0 || error == 0,
		    ("LK_RETRY set with incompatible flags (0x%x) or an error occurred (%d)",
		    flags, error));
		if (error == 0 && vp->v_iflag & VI_DOOMED &&
		    (flags & LK_RETRY) == 0) {
			VOP_UNLOCK(vp, 0);
			error = ENOENT;
			break;
		}
	} while (flags & LK_RETRY && error != 0);
	return (error);
}
int _vn_lock ( struct vnode * vp , int flags , char * file , int line ) { int error ; VNASSERT ( ( flags & LK_TYPE_MASK ) != 0 , vp , ( " " ) ) ; do { #ifdef DEBUG_VFS_LOCKS KASSERT ( vp -> v_holdcnt != 0 , ( " " , vp ) ) ; #endif error = VOP_LOCK1 ( vp , flags , file , line ) ; flags &= ~ LK_INTERLOCK ; KASSERT ( ( flags & LK_RETRY ) == 0 || error == 0 , ( " " , flags , error ) ) ; if ( error == 0 && vp -> v_iflag & VI_DOOMED && ( flags & LK_RETRY ) == 0 ) { VOP_UNLOCK ( vp , 0 ) ; error = ENOENT ; break ; } } while ( flags & LK_RETRY && error != 0 ) ; return ( error ) ; }
Acquire the requested lock and then check for validity.
Acquire the requested lock and then check for validity .
/* Interlock is always dropped. */ /*
		 * Callers specify LK_RETRY if they wish to get dead vnodes.
		 * If RETRY is not set, we return ENOENT instead.
		 */