diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5452,14 +5452,17 @@ void assert_vop_locked(struct vnode *vp, const char *str) { - int locked; - if (KERNEL_PANICKED() || vp == NULL) return; - locked = VOP_ISLOCKED(vp); +#ifdef WITNESS + witness_assert(&vp->v_vnlock->lock_object, LA_LOCKED, + __FILE__, __LINE__); +#else + int locked = VOP_ISLOCKED(vp); if (locked == 0 || locked == LK_EXCLOTHER) vfs_badlock("is not locked but should be", str, vp); +#endif } void @@ -5468,8 +5471,13 @@ if (KERNEL_PANICKED() || vp == NULL) return; +#ifdef WITNESS + witness_assert(&vp->v_vnlock->lock_object, LA_UNLOCKED, + __FILE__, __LINE__); +#else if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) vfs_badlock("is locked but should not be", str, vp); +#endif } void