summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2002-07-02 04:23:26 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2002-07-02 04:23:26 +0000
commitad16a186ab94f8057bd5190ca3a2366befb04bdf (patch)
tree2060791967256ae94b98106660027413ab848cfa /sys/kern
parent3f603b9f00624ca6f35f817e0668692f7c57b1d8 (diff)
use hash.h for nfs_hash as well as namei's hash
ok art@ costa@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_cache.c9
-rw-r--r--sys/kern/vfs_lookup.c16
2 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 4d367cf3f3c..16be7656747 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_cache.c,v 1.6 2002/01/23 00:39:48 art Exp $ */
+/* $OpenBSD: vfs_cache.c,v 1.7 2002/07/02 04:23:25 ericj Exp $ */
/* $NetBSD: vfs_cache.c,v 1.13 1996/02/04 02:18:09 christos Exp $ */
/*
@@ -45,6 +45,7 @@
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/pool.h>
+#include <sys/hash.h>
/*
* Name caching works as follows:
@@ -109,7 +110,8 @@ cache_lookup(dvp, vpp, cnp)
cnp->cn_flags &= ~MAKEENTRY;
return (0);
}
- ncpp = &nchashtbl[(cnp->cn_hash ^ dvp->v_id) & nchash];
+ ncpp = &nchashtbl[
+ hash32_buf(&dvp->v_id, sizeof(dvp->v_id), cnp->cn_hash) & nchash];
for (ncp = ncpp->lh_first; ncp != 0; ncp = ncp->nc_hash.le_next) {
if (ncp->nc_dvp == dvp &&
ncp->nc_dvpid == dvp->v_id &&
@@ -217,7 +219,8 @@ cache_enter(dvp, vp, cnp)
ncp->nc_nlen = cnp->cn_namelen;
bcopy(cnp->cn_nameptr, ncp->nc_name, (unsigned)ncp->nc_nlen);
TAILQ_INSERT_TAIL(&nclruhead, ncp, nc_lru);
- ncpp = &nchashtbl[(cnp->cn_hash ^ dvp->v_id) & nchash];
+ ncpp = &nchashtbl[
+ hash32_buf(&dvp->v_id, sizeof(dvp->v_id), cnp->cn_hash) & nchash];
LIST_INSERT_HEAD(ncpp, ncp, nc_hash);
}
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index e354cea4b5d..dc97cfe1eff 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_lookup.c,v 1.19 2001/06/22 14:14:10 deraadt Exp $ */
+/* $OpenBSD: vfs_lookup.c,v 1.20 2002/07/02 04:23:25 ericj Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */
/*
@@ -52,6 +52,7 @@
#include <sys/malloc.h>
#include <sys/filedesc.h>
#include <sys/proc.h>
+#include <sys/hash.h>
#ifdef KTRACE
#include <sys/ktrace.h>
@@ -280,8 +281,8 @@ int
lookup(ndp)
register struct nameidata *ndp;
{
- register char *cp; /* pointer into pathname argument */
- register struct vnode *dp = 0; /* the directory we are searching */
+ char *cp; /* pointer into pathname argument */
+ struct vnode *dp = 0; /* the directory we are searching */
struct vnode *tdp; /* saved dp */
struct mount *mp; /* mount table entry */
int docache; /* == 0 do not cache last component */
@@ -350,10 +351,9 @@ dirloop:
* the name set the SAVENAME flag. When done, they assume
* responsibility for freeing the pathname buffer.
*/
+ cp = NULL;
cnp->cn_consume = 0;
- cnp->cn_hash = 0;
- for (cp = cnp->cn_nameptr; *cp != '\0' && *cp != '/'; cp++)
- cnp->cn_hash += (unsigned char)*cp;
+ cnp->cn_hash = hash32_stre(cnp->cn_nameptr, '/', &cp, HASHINIT);
cnp->cn_namelen = cp - cnp->cn_nameptr;
if (cnp->cn_namelen > NAME_MAX) {
error = ENAMETOOLONG;
@@ -637,8 +637,8 @@ relookup(dvp, vpp, cnp)
* responsibility for freeing the pathname buffer.
*/
#ifdef NAMEI_DIAGNOSTIC
- for (newhash = 0, cp = cnp->cn_nameptr; *cp != 0 && *cp != '/'; cp++)
- newhash += (unsigned char)*cp;
+ cp = NULL;
+ newhash = hash32_stre(cnp->cn_nameptr, '/', &cp, HASHINIT);
if (newhash != cnp->cn_hash)
panic("relookup: bad hash");
if (cnp->cn_namelen != cp - cnp->cn_nameptr)