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.
This commit is contained in:
parent
84b2995b2f
commit
90769c9ed0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98985
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user