diff options
author | peter <peter@FreeBSD.org> | 2001-03-20 02:10:18 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2001-03-20 02:10:18 +0000 |
commit | 266cea85ee85a1343c8d97993dc1f12fadb5db16 (patch) | |
tree | 4495c0a2e78047767d7f26e6af5e514fa392252f /sys/kern/vfs_cache.c | |
parent | e1c06db9614adac5dbc0db3be048e6d3bb916b61 (diff) | |
download | FreeBSD-src-266cea85ee85a1343c8d97993dc1f12fadb5db16.zip FreeBSD-src-266cea85ee85a1343c8d97993dc1f12fadb5db16.tar.gz |
Use the same API as the example code.
Allow the initial hash value to be passed in, as the examples do.
Incrementally hash in the dvp->v_id (using the official api) rather than
add it. This seems to help power-of-two predictable filename trees
where the filenames repeat on a power-of-two cycle and the directory trees
have power-of-two components in it. The simple add then mask was causing
things like 12000+ entry collision chains while most other entries have
between 0 and 3 entries each. This way seems to improve things.
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r-- | sys/kern/vfs_cache.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 3f92c8f..3459917 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -86,8 +86,8 @@ struct namecache { /* * Structures associated with name cacheing. */ -#define NCHHASH(dvp, hash) \ - (&nchashtbl[((dvp)->v_id + (hash)) & nchash]) +#define NCHHASH(hash) \ + (&nchashtbl[(hash) & nchash]) static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */ static TAILQ_HEAD(, namecache) ncneg; /* Hash Table */ static u_long nchash; /* size of hash table */ @@ -208,8 +208,9 @@ cache_lookup(dvp, vpp, cnp) } } - hash = fnv32_hashbuf(cnp->cn_nameptr, cnp->cn_namelen); - LIST_FOREACH(ncp, (NCHHASH(dvp, hash)), nc_hash) { + hash = fnv_32_buf(cnp->cn_nameptr, cnp->cn_namelen, FNV1_32_INIT); + hash = fnv_32_buf(&dvp->v_id, sizeof(dvp->v_id), hash); + LIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) { numchecks++; if (ncp->nc_dvp == dvp && ncp->nc_nlen == cnp->cn_namelen && !bcmp(ncp->nc_name, cnp->cn_nameptr, ncp->nc_nlen)) @@ -318,9 +319,10 @@ cache_enter(dvp, vp, cnp) ncp->nc_vp = vp; ncp->nc_dvp = dvp; len = ncp->nc_nlen = cnp->cn_namelen; - hash = fnv32_hashbuf(cnp->cn_nameptr, len); + hash = fnv_32_buf(cnp->cn_nameptr, len, FNV1_32_INIT); bcopy(cnp->cn_nameptr, ncp->nc_name, len); - ncpp = NCHHASH(dvp, hash); + hash = fnv_32_buf(&dvp->v_id, sizeof(dvp->v_id), hash); + ncpp = NCHHASH(hash); LIST_INSERT_HEAD(ncpp, ncp, nc_hash); if (LIST_EMPTY(&dvp->v_cache_src)) vhold(dvp); |