DEBUG_VFS_LOCKS: stop excluding devfs and doomed vnode from asserts
We do not require devvp vnode locked for metadata io. It is typically not needed indeed, since correctness of the file system using corresponding block device ensures that there is no incorrect or racy manipulations. But right now DEBUG_VFS_LOCKS option excludes both character device vnodes and completely destroyed (VBAD) vnodes from asserts. This is not too bad since WITNESS still ensures that we do not leak locks. On the other hand, asserts do not mean what they should, to the reader, and reliance on them being enforced might result in wrong code. Note that ASSERT_VOP_LOCKED() still silently accepts NULLVP, I think it is worth fixing as well, in the next round. In collaboration with: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D32761
This commit is contained in:
parent
47b248ac65
commit
d032cda0d0
@ -5365,13 +5365,6 @@ extattr_check_cred(struct vnode *vp, int attrnamespace, struct ucred *cred,
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VFS_LOCKS
|
||||
/*
|
||||
* This only exists to suppress warnings from unlocked specfs accesses. It is
|
||||
* no longer ok to have an unlocked VFS.
|
||||
*/
|
||||
#define IGNORE_LOCK(vp) (KERNEL_PANICKED() || (vp) == NULL || \
|
||||
(vp)->v_type == VCHR || (vp)->v_type == VBAD)
|
||||
|
||||
int vfs_badlock_ddb = 1; /* Drop into debugger on violation. */
|
||||
SYSCTL_INT(_debug, OID_AUTO, vfs_badlock_ddb, CTLFLAG_RW, &vfs_badlock_ddb, 0,
|
||||
"Drop into debugger on lock violation");
|
||||
@ -5431,26 +5424,31 @@ assert_vop_locked(struct vnode *vp, const char *str)
|
||||
{
|
||||
int locked;
|
||||
|
||||
if (!IGNORE_LOCK(vp)) {
|
||||
if (KERNEL_PANICKED() || vp == NULL)
|
||||
return;
|
||||
|
||||
locked = VOP_ISLOCKED(vp);
|
||||
if (locked == 0 || locked == LK_EXCLOTHER)
|
||||
vfs_badlock("is not locked but should be", str, vp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
assert_vop_unlocked(struct vnode *vp, const char *str)
|
||||
{
|
||||
if (KERNEL_PANICKED() || vp == NULL)
|
||||
return;
|
||||
|
||||
if (!IGNORE_LOCK(vp) && VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
|
||||
if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
|
||||
vfs_badlock("is locked but should not be", str, vp);
|
||||
}
|
||||
|
||||
void
|
||||
assert_vop_elocked(struct vnode *vp, const char *str)
|
||||
{
|
||||
if (KERNEL_PANICKED() || vp == NULL)
|
||||
return;
|
||||
|
||||
if (!IGNORE_LOCK(vp) && VOP_ISLOCKED(vp) != LK_EXCLUSIVE)
|
||||
if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE)
|
||||
vfs_badlock("is not exclusive locked but should be", str, vp);
|
||||
}
|
||||
#endif /* DEBUG_VFS_LOCKS */
|
||||
|
Loading…
Reference in New Issue
Block a user