From ef1b5135a944eaca4ee229eb22b7fda38043f8c5 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 29 Mar 2008 23:36:26 +0000 Subject: [PATCH] - 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. --- sys/kern/vfs_vnops.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7d2a132f9a4..1b08156ca49 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -854,26 +854,16 @@ vn_poll(fp, events, active_cred, td) } /* - * Check that the vnode is still valid, and if so - * acquire requested lock. + * 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; - /* - * With no lock type requested we're just polling for validity. - */ - 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); - } + VNASSERT((flags & LK_TYPE_MASK) != 0, vp, + ("vn_lock called with no locktype.")); do { error = VOP_LOCK1(vp, flags, file, line); flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */ -- 2.45.0