git: 074babfb2812 - stable/13 - DEBUG_VFS_LOCKS: use witness if available
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Apr 2023 10:57:40 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=074babfb2812c12caf99e3286f0a6c688ecf45bf commit 074babfb2812c12caf99e3286f0a6c688ecf45bf Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-04-08 06:15:00 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-04-16 10:45:58 +0000 DEBUG_VFS_LOCKS: use witness if available (cherry picked from commit 7b6fe2428a97921e8df882d0a24b87094c37b468) --- sys/kern/vfs_lookup.c | 1 + sys/kern/vfs_subr.c | 16 +++++++++++++--- sys/sys/vnode.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 3ded2180ac82..b7ce93f3702d 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -161,6 +161,7 @@ nameiinit(void *dummy __unused) UMA_ALIGN_PTR, 0); vfs_vector_op_register(&crossmp_vnodeops); getnewvnode("crossmp", NULL, &crossmp_vnodeops, &vp_crossmp); + vp_crossmp->v_irflag |= VIRF_CROSSMP; } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 67f707dd9edb..c4d8ceac7e2b 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5526,14 +5526,18 @@ assert_vi_unlocked(struct vnode *vp, const char *str) void assert_vop_locked(struct vnode *vp, const char *str) { - int locked; - if (KERNEL_PANICKED() || vp == NULL) return; - locked = VOP_ISLOCKED(vp); +#ifdef WITNESS + if ((vp->v_irflag & VIRF_CROSSMP) == 0) + 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 @@ -5542,8 +5546,14 @@ assert_vop_unlocked(struct vnode *vp, const char *str) if (KERNEL_PANICKED() || vp == NULL) return; +#ifdef WITNESS + if ((vp->v_irflag & VIRF_CROSSMP) == 0) + 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 diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 2011f429141c..37cafdb0d5ae 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -248,6 +248,7 @@ struct xvnode { #define VIRF_PGREAD 0x0002 /* Direct reads from the page cache are permitted, never cleared once set */ #define VIRF_MOUNTPOINT 0x0004 /* This vnode is mounted on */ +#define VIRF_CROSSMP 0x0010 /* Cross-mp vnode, no locking */ #define VI_TEXT_REF 0x0001 /* Text ref grabbed use ref */ #define VI_MOUNT 0x0002 /* Mount in progress */