Skip to content

Commit a7aac8c

Browse files
committed
vnode: Assert that VOP_LOCK succeeds in freevnode()
Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52245
1 parent bed2299 commit a7aac8c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sys/kern/vfs_subr.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,8 @@ freevnode(struct vnode *vp)
21862186
{
21872187
struct bufobj *bo;
21882188

2189+
ASSERT_VOP_UNLOCKED(vp, __func__);
2190+
21892191
/*
21902192
* The vnode has been marked for destruction, so free it.
21912193
*
@@ -2222,12 +2224,16 @@ freevnode(struct vnode *vp)
22222224
mac_vnode_destroy(vp);
22232225
#endif
22242226
if (vp->v_pollinfo != NULL) {
2227+
int error __diagused;
2228+
22252229
/*
22262230
* Use LK_NOWAIT to shut up witness about the lock. We may get
22272231
* here while having another vnode locked when trying to
22282232
* satisfy a lookup and needing to recycle.
22292233
*/
2230-
VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT);
2234+
error = VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT);
2235+
VNASSERT(error == 0, vp,
2236+
("freevnode: cannot lock vp %p for pollinfo destroy", vp));
22312237
destroy_vpollinfo(vp->v_pollinfo);
22322238
VOP_UNLOCK(vp);
22332239
vp->v_pollinfo = NULL;

0 commit comments

Comments
 (0)