diff options
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r-- | sys/kern/vfs_cache.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 6657523..3f92c8f 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -48,6 +48,7 @@ #include <sys/sysproto.h> #include <sys/proc.h> #include <sys/filedesc.h> +#include <sys/fnv_hash.h> /* * This structure describes the elements in the cache of recent @@ -180,9 +181,7 @@ cache_lookup(dvp, vpp, cnp) struct componentname *cnp; { struct namecache *ncp; - u_long hash; - u_char *cp; - int len; + u_int32_t hash; if (!doingcache) { cnp->cn_flags &= ~MAKEENTRY; @@ -209,10 +208,7 @@ cache_lookup(dvp, vpp, cnp) } } - hash = 0; - len = cnp->cn_namelen; - for (cp = cnp->cn_nameptr; len; len--, cp++) - hash += *cp; + hash = fnv32_hashbuf(cnp->cn_nameptr, cnp->cn_namelen); LIST_FOREACH(ncp, (NCHHASH(dvp, hash)), nc_hash) { numchecks++; if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen && @@ -279,8 +275,7 @@ cache_enter(dvp, vp, cnp) { struct namecache *ncp; struct nchashhead *ncpp; - u_long hash; - u_char *cp, *dp; + u_int32_t hash; int len; if (!doingcache) @@ -323,10 +318,8 @@ cache_enter(dvp, vp, cnp) ncp->nc_vp = vp; ncp->nc_dvp = dvp; len = ncp->nc_nlen = cnp->cn_namelen; - hash = 0; - dp = ncp->nc_name; - for (cp = cnp->cn_nameptr; len; len--, cp++, dp++) - hash += (*dp = *cp); + hash = fnv32_hashbuf(cnp->cn_nameptr, len); + bcopy(cnp->cn_nameptr, ncp->nc_name, len); ncpp = NCHHASH(dvp, hash); LIST_INSERT_HEAD(ncpp, ncp, nc_hash); if (LIST_EMPTY(&dvp->v_cache_src)) |