Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern When creating a vnode with vcache_get() mark the vn...



details:   https://anonhg.NetBSD.org/src/rev/edbbcee60524
branches:  trunk
changeset: 332681:edbbcee60524
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Oct 03 14:45:38 2014 +0000

description:
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).

diffstat:

 sys/kern/vfs_vnode.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r b34cfa0e0fc0 -r edbbcee60524 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Fri Oct 03 12:41:41 2014 +0000
+++ b/sys/kern/vfs_vnode.c      Fri Oct 03 14:45:38 2014 +0000
@@ -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 @@
        }
 
        /* 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 @@
        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;
 }



Home | Main Index | Thread Index | Old Index