Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/smbfs smbfs_node_alloc():
details: https://anonhg.NetBSD.org/src/rev/997972f4a6b2
branches: trunk
changeset: 543407:997972f4a6b2
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Feb 24 15:55:08 2003 +0000
description:
smbfs_node_alloc():
* use LK_RETRY for the vget()
* turn the check for dead parent vnode to #ifdef DIAGNOSTIC panic
* reformat the hash walk code a little, and only assign vp if entries match
* add some comments
diffstat:
sys/fs/smbfs/smbfs_node.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diffs (64 lines):
diff -r 7a61a47e6f39 -r 997972f4a6b2 sys/fs/smbfs/smbfs_node.c
--- a/sys/fs/smbfs/smbfs_node.c Mon Feb 24 15:14:51 2003 +0000
+++ b/sys/fs/smbfs/smbfs_node.c Mon Feb 24 15:55:08 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smbfs_node.c,v 1.8 2003/02/23 21:55:20 jdolecek Exp $ */
+/* $NetBSD: smbfs_node.c,v 1.9 2003/02/24 15:55:08 jdolecek Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@@ -152,26 +152,27 @@
if (dvp == NULL)
return EINVAL;
vp = VTOSMB(dvp)->n_parent->n_vnode;
- if ((error = vget(vp, LK_EXCLUSIVE)) == 0)
+ if ((error = vget(vp, LK_EXCLUSIVE | LK_RETRY)) == 0)
*vpp = vp;
return (error);
}
dnp = dvp ? VTOSMB(dvp) : NULL;
- if (dnp == NULL && dvp != NULL) {
- vprint("smbfs_node_alloc: dead parent vnode", dvp);
- return EINVAL;
- }
+#ifdef DIAGNOSTIC
+ if (dnp == NULL && dvp != NULL)
+ panic("smbfs_node_alloc: dead parent vnode %p", dvp);
+#endif
hashval = smbfs_hash(name, nmlen);
retry:
smbfs_hash_lock(smp);
loop:
nhpp = SMBFS_NOHASH(smp, hashval);
LIST_FOREACH(np, nhpp, n_hash) {
+ if (np->n_parent != dnp
+ || np->n_nmlen != nmlen
+ || memcmp(name, np->n_name, nmlen) != 0)
+ continue;
vp = SMBTOV(np);
- if (np->n_parent != dnp ||
- np->n_nmlen != nmlen || memcmp(name, np->n_name, nmlen) != 0)
- continue;
simple_lock(&(vp)->v_interlock);
smbfs_hash_unlock(smp);
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK) != 0)
@@ -219,6 +220,10 @@
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
smbfs_hash_lock(smp);
+ /*
+ * Check if the vnode wasn't added while we were in getnewvnode/
+ * malloc.
+ */
LIST_FOREACH(np2, nhpp, n_hash) {
if (np2->n_parent != dnp
|| np2->n_nmlen != nmlen
@@ -228,6 +233,7 @@
goto loop;
}
+ /* Not on hash list, add it now */
LIST_INSERT_HEAD(nhpp, np, n_hash);
smbfs_hash_unlock(smp);
Home |
Main Index |
Thread Index |
Old Index