Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/genfs When layer_node_alloc() finds another threa...
details: https://anonhg.NetBSD.org/src/rev/886303c77e1b
branches: trunk
changeset: 326649:886303c77e1b
user: hannken <hannken%NetBSD.org@localhost>
date: Sun Feb 09 17:15:51 2014 +0000
description:
When layer_node_alloc() finds another thread already inserted the node
into the hashlist and discards the now unneeded node it will raise a
panic "dead but not clean".
Reorder the initialization and use ungetnewvnode() to discard the node.
diffstat:
sys/miscfs/genfs/layer_subr.c | 35 ++++++++++++++---------------------
1 files changed, 14 insertions(+), 21 deletions(-)
diffs (70 lines):
diff -r 5b865eb03508 -r 886303c77e1b sys/miscfs/genfs/layer_subr.c
--- a/sys/miscfs/genfs/layer_subr.c Sun Feb 09 17:07:41 2014 +0000
+++ b/sys/miscfs/genfs/layer_subr.c Sun Feb 09 17:15:51 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $ */
+/* $NetBSD: layer_subr.c,v 1.34 2014/02/09 17:15:51 hannken Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.34 2014/02/09 17:15:51 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -187,7 +187,6 @@
struct layer_node *xp;
struct vnode *vp, *nvp;
int error;
- extern int (**dead_vnodeop_p)(void *);
/* Get a new vnode and share its interlock with underlying vnode. */
error = getnewvnode(lmp->layerm_tag, mp, lmp->layerm_vnodeop_p,
@@ -209,6 +208,18 @@
spec_node_init(vp, lowervp->v_rdev);
}
+ /*
+ * Before inserting the node into the hash, check if other thread
+ * did not race with us. If so - return that node, destroy ours.
+ */
+ mutex_enter(&lmp->layerm_hashlock);
+ if ((nvp = layer_node_find(mp, lowervp)) != NULL) {
+ ungetnewvnode(vp);
+ kmem_free(xp, lmp->layerm_size);
+ *vpp = nvp;
+ return 0;
+ }
+
vp->v_data = xp;
vp->v_vflag = (vp->v_vflag & ~VV_MPSAFE) |
(lowervp->v_vflag & VV_MPSAFE);
@@ -217,24 +228,6 @@
xp->layer_flags = 0;
/*
- * Before inserting the node into the hash, check if other thread
- * did not race with us. If so - return that node, destroy ours.
- */
- mutex_enter(&lmp->layerm_hashlock);
- if ((nvp = layer_node_find(mp, lowervp)) != NULL) {
- /* Free the structures we have created. */
- if (vp->v_type == VBLK || vp->v_type == VCHR)
- spec_node_destroy(vp);
-
- vp->v_type = VBAD; /* node is discarded */
- vp->v_op = dead_vnodeop_p; /* so ops will still work */
- vrele(vp); /* get rid of it. */
- kmem_free(xp, lmp->layerm_size);
- *vpp = nvp;
- return 0;
- }
-
- /*
* Insert the new node into the hash.
* Add a reference to the lower node.
*/
Home |
Main Index |
Thread Index |
Old Index