Module Name:    src
Committed By:   hannken
Date:           Fri Oct  3 14:45:38 UTC 2014

Modified Files:
        src/sys/kern: vfs_vnode.c

Log Message:
When creating a vnode with vcache_get() mark the vnode VI_CHANGING until
it is fully initialised.  It may be on the specnode list before it is
fully initialised and revoking it then would panic.

Should prevent the panic from PR kern/49171 (panic when closing a pty).


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/vfs_vnode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.38 src/sys/kern/vfs_vnode.c:1.39
--- src/sys/kern/vfs_vnode.c:1.38	Fri Sep  5 05:57:21 2014
+++ src/sys/kern/vfs_vnode.c	Fri Oct  3 14:45:38 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.38 2014/09/05 05:57:21 matt Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.39 2014/10/03 14:45:38 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -116,7 +116,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.38 2014/09/05 05:57:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.39 2014/10/03 14:45:38 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -1293,6 +1293,7 @@ again:
 	}
 
 	/* Load the fs node.  Exclusive as new_node->vn_vnode is NULL. */
+	vp->v_iflag |= VI_CHANGING;
 	error = VFS_LOADVNODE(mp, vp, key, key_len, &new_key);
 	if (error) {
 		mutex_enter(&vcache.lock);
@@ -1320,6 +1321,10 @@ again:
 	new_node->vn_key.vk_key = new_key;
 	new_node->vn_vnode = vp;
 	mutex_exit(&vcache.lock);
+	mutex_enter(vp->v_interlock);
+	vp->v_iflag &= ~VI_CHANGING;
+	cv_broadcast(&vp->v_cv);
+	mutex_exit(vp->v_interlock);
 	*vpp = vp;
 	return 0;
 }

Reply via email to