summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-06-28 20:58:14 +0000
committerjeff <jeff@FreeBSD.org>2002-06-28 20:58:14 +0000
commit1ed9e0f3759b38531dd3735e14ab04f36afb0941 (patch)
tree32f110f5a8a14ee922bff54789ce1da2322cd005 /sys
parent792737cf4d98d3af06c2946642a2cf3409e03e1b (diff)
downloadFreeBSD-src-1ed9e0f3759b38531dd3735e14ab04f36afb0941.zip
FreeBSD-src-1ed9e0f3759b38531dd3735e14ab04f36afb0941.tar.gz
Improve the VOP locking asserts
- Add vfs_badlock_print to control whether or not we print lock violations - Add vfs_badlock_panic to control whether we panic on lock violations Both default to on to mimic the original behavior if DEBUG_VFS_LOCKS is on.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c7
-rw-r--r--sys/sys/vnode.h22
2 files changed, 24 insertions, 5 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index d75321c..a4581df 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -236,6 +236,13 @@ static int vnlru_nowhere;
SYSCTL_INT(_debug, OID_AUTO, vnlru_nowhere, CTLFLAG_RW, &vnlru_nowhere, 0,
"Number of times the vnlru process ran without success");
+#ifdef DEBUG_VFS_LOCKS
+/* Print lock violations */
+int vfs_badlock_print = 1;
+/* Panic on violation */
+int vfs_badlock_panic = 1;
+#endif
+
void
v_addpollinfo(struct vnode *vp)
{
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index be774bd..0bace92 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -447,6 +447,9 @@ struct vop_generic_args {
* is a pretty good test.
*/
+extern int vfs_badlock_panic;
+extern int vfs_badlock_print;
+
/*
* [dfr] Kludge until I get around to fixing all the vfs locking.
*/
@@ -462,8 +465,13 @@ struct vop_generic_args {
do { \
struct vnode *_vp = (vp); \
\
- if (_vp && IS_LOCKING_VFS(_vp) && !VOP_ISLOCKED(_vp, NULL)) \
- panic("%s: %p is not locked but should be", str, _vp); \
+ if (_vp && IS_LOCKING_VFS(_vp) && !VOP_ISLOCKED(_vp, NULL)) { \
+ if (vfs_badlock_print) \
+ printf("%s: %p is not locked but should be", \
+ str, _vp); \
+ if (vfs_badlock_panic) \
+ Debugger("Lock violation.\n"); \
+ } \
} while (0)
#define ASSERT_VOP_UNLOCKED(vp, str) \
@@ -473,9 +481,13 @@ do { \
\
if (_vp && IS_LOCKING_VFS(_vp)) { \
lockstate = VOP_ISLOCKED(_vp, curthread); \
- if (lockstate == LK_EXCLUSIVE) \
- panic("%s: %p is locked but should not be", \
- str, _vp); \
+ if (lockstate == LK_EXCLUSIVE) { \
+ if (vfs_badlock_print) \
+ printf("%s: %p is locked but should not be", \
+ str, _vp); \
+ if (vfs_badlock_panic) \
+ Debugger("Lock Violation.\n"); \
+ } \
} \
} while (0)
OpenPOWER on IntegriCloud