diff options
-rw-r--r-- | sys/kern/vfs_cache.c | 9 | ||||
-rw-r--r-- | sys/kern/vfs_lookup.c | 16 | ||||
-rw-r--r-- | sys/nfs/nfs_node.c | 24 | ||||
-rw-r--r-- | sys/nfs/nfs_var.h | 3 |
4 files changed, 19 insertions, 33 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) diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index 4b4294ae434..f4d24471f4f 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_node.c,v 1.24 2002/03/14 01:27:13 millert Exp $ */ +/* $OpenBSD: nfs_node.c,v 1.25 2002/07/02 04:23:25 ericj Exp $ */ /* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */ /* @@ -49,6 +49,7 @@ #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/pool.h> +#include <sys/hash.h> #include <nfs/rpcv2.h> #include <nfs/nfsproto.h> @@ -68,6 +69,8 @@ extern int prtactive; #define TRUE 1 #define FALSE 0 +#define nfs_hash(x,y) hash32_buf((x), (y), HASHINIT) + /* * Initialize hash links for nfsnodes * and build nfsnode free list. @@ -83,25 +86,6 @@ nfs_nhinit() } /* - * Compute an entry in the NFS hash table structure - */ -u_long -nfs_hash(fhp, fhsize) - nfsfh_t *fhp; - int fhsize; -{ - u_char *fhpp; - u_long fhsum; - int i; - - fhpp = &fhp->fh_bytes[0]; - fhsum = 0; - for (i = 0; i < fhsize; i++) - fhsum += *fhpp++; - return (fhsum); -} - -/* * Look up a vnode/nfsnode by file handle. * Callers must check for mount points!! * In all cases, a pointer to a diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h index d985877e700..517ecd76d14 100644 --- a/sys/nfs/nfs_var.h +++ b/sys/nfs/nfs_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_var.h,v 1.19 2002/04/10 18:16:46 csapuntz Exp $ */ +/* $OpenBSD: nfs_var.h,v 1.20 2002/07/02 04:23:25 ericj Exp $ */ /* $NetBSD: nfs_var.h,v 1.3 1996/02/18 11:53:54 fvdl Exp $ */ /* @@ -75,7 +75,6 @@ int nfs_boot_init(struct nfs_diskless *, struct proc *); /* nfs_node.c */ void nfs_nhinit(void); -u_long nfs_hash(nfsfh_t *, int); int nfs_nget(struct mount *, nfsfh_t *, int, struct nfsnode **); int nfs_inactive(void *); int nfs_reclaim(void *); |