summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2008-03-29 23:36:26 +0000
committerjeff <jeff@FreeBSD.org>2008-03-29 23:36:26 +0000
commitef1b5135a944eaca4ee229eb22b7fda38043f8c5 (patch)
tree39f9342e6083b171a7cdadf4becb9b31e2d7cf27 /sys/kern/vfs_vnops.c
parent26629f5add30a8592d5c987266c9944bce79c21e (diff)
downloadFreeBSD-src-ef1b5135a944eaca4ee229eb22b7fda38043f8c5.zip
FreeBSD-src-ef1b5135a944eaca4ee229eb22b7fda38043f8c5.tar.gz
- 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.
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 7d2a132..1b08156 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. */
OpenPOWER on IntegriCloud