Tue Dec 20 16:49:37 2011 UTC ()
Move the diagnostic check for a missing VOP_CLOSE() to the top of vrelel().
As long as we hold the vnode interlock there is no chance for this vnode
to gain new references.

Fixes false alarms observed by Thor Lancelot Simon and reported on tech-kern.

Ok: David Holland <dholland@netbsd.org>


(hannken)
diff -r1.14 -r1.15 src/sys/kern/vfs_vnode.c

cvs diff -r1.14 -r1.15 src/sys/kern/vfs_vnode.c (expand / switch to context diff)
--- src/sys/kern/vfs_vnode.c 2011/10/07 09:35:06 1.14
+++ src/sys/kern/vfs_vnode.c 2011/12/20 16:49:37 1.15
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -120,7 +120,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.15 2011/12/20 16:49:37 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -637,6 +637,13 @@
 
 	KASSERT((vp->v_iflag & VI_XLOCK) == 0);
 
+#ifdef DIAGNOSTIC
+	if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
+	    vp->v_specnode != NULL && vp->v_specnode->sn_opencnt != 0) {
+		vprint("vrelel: missing VOP_CLOSE()", vp);
+	}
+#endif
+
 	/*
 	 * If not clean, deactivate the vnode, but preserve
 	 * our reference across the call to VOP_INACTIVE().
@@ -705,13 +712,6 @@
 			mutex_exit(vp->v_interlock);
 			return;
 		}
-
-#ifdef DIAGNOSTIC
-		if ((vp->v_type == VBLK || vp->v_type == VCHR) &&
-		    vp->v_specnode != NULL && vp->v_specnode->sn_opencnt != 0) {
-			vprint("vrelel: missing VOP_CLOSE()", vp);
-		}
-#endif
 
 		/*
 		 * The vnode can gain another reference while being