The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a7aac8c20497d1666a15f160ef99acddd55a1365
commit a7aac8c20497d1666a15f160ef99acddd55a1365 Author: Mark Johnston <ma...@freebsd.org> AuthorDate: 2025-08-30 14:56:58 +0000 Commit: Mark Johnston <ma...@freebsd.org> CommitDate: 2025-08-30 14:56:58 +0000 vnode: Assert that VOP_LOCK succeeds in freevnode() Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52245 --- sys/kern/vfs_subr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index a6e38be89291..57732ddab7d9 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2186,6 +2186,8 @@ freevnode(struct vnode *vp) { struct bufobj *bo; + ASSERT_VOP_UNLOCKED(vp, __func__); + /* * The vnode has been marked for destruction, so free it. * @@ -2222,12 +2224,16 @@ freevnode(struct vnode *vp) mac_vnode_destroy(vp); #endif if (vp->v_pollinfo != NULL) { + int error __diagused; + /* * Use LK_NOWAIT to shut up witness about the lock. We may get * here while having another vnode locked when trying to * satisfy a lookup and needing to recycle. */ - VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT); + error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT); + VNASSERT(error == 0, vp, + ("freevnode: cannot lock vp %p for pollinfo destroy", vp)); destroy_vpollinfo(vp->v_pollinfo); VOP_UNLOCK(vp); vp->v_pollinfo = NULL;