summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2008-10-20 10:11:33 +0000
committerkib <kib@FreeBSD.org>2008-10-20 10:11:33 +0000
commite4785f6af46f6a5f0dc78c7eeb246a7d300652bb (patch)
tree19e1a3741bbd1de5ea7c4c9b19df66c5f0e37a4b
parent015479d466a4e5609bed16fe5bc0d7c02cd1a239 (diff)
downloadFreeBSD-src-e4785f6af46f6a5f0dc78c7eeb246a7d300652bb.zip
FreeBSD-src-e4785f6af46f6a5f0dc78c7eeb246a7d300652bb.tar.gz
Assert that v_holdcnt is non-zero before entering lockmgr in vn_lock
and ffs_lock. This cannot catch situations where holdcnt is incremented not by curthread, but I think it is useful. Reviewed by: tegge, attilio Tested by: pho MFC after: 2 weeks
-rw-r--r--sys/kern/vfs_vnops.c4
-rw-r--r--sys/ufs/ffs/ffs_vnops.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 2301a34..c730781 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -873,6 +873,10 @@ _vn_lock(struct vnode *vp, int flags, char *file, int line)
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; /* Interlock is always dropped. */
KASSERT((flags & LK_RETRY) == 0 || error == 0,
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 7b1af28..38dc2b6 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -361,6 +361,10 @@ ffs_lock(ap)
vp = ap->a_vp;
flags = ap->a_flags;
for (;;) {
+#ifdef DEBUG_VFS_LOCKS
+ KASSERT(vp->v_holdcnt != 0,
+ ("ffs_lock %p: zero hold count", vp));
+#endif
lkp = vp->v_vnlock;
result = _lockmgr_args(lkp, flags, VI_MTX(vp),
LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
OpenPOWER on IntegriCloud