Fixed the hash formula. Lite2 doesn't have phashinit(), so Lite2's hash
formula uses `& nchash'. This is very broken when nchash is a prime number instead of 1 less than a power of 2, but the Lite2 formula was merged in. Merged some cosmetic changes from Lite2, rev.1.21 and Lite1. The merge was difficult because the Lite2 code is essentially ours (phk's) except where Lite2 improved or broke it. Summary of the Lite2 changes: - in the copyright, phk's rights have been transferred to the Regents. This change should be reviewed. - nchENOENT went away; the "no" vnode is now simply 0. - comments were improved. - style was "improved". - goto instead of Fanatism (sic) was considered bad :-). - there are some small changes to support whiteouts. - new cache entries are added in more cases. More work is required near here to change the hash table size if kern.desiredvnodes is changed using sysctl. - rescanning of the hash bucket in cache_purgevfs() was removed. This change should be reviewed.
This commit is contained in:
parent
dfd0621acc
commit
d8d6519c63
@ -33,8 +33,8 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94
|
||||
* $Id$
|
||||
* @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95
|
||||
* $Id: vfs_cache.c,v 1.23 1997/02/22 09:39:31 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -75,15 +75,16 @@
|
||||
* Structures associated with name cacheing.
|
||||
*/
|
||||
#define NCHHASH(dvp, cnp) \
|
||||
(&nchashtbl[((dvp)->v_id + (cnp)->cn_hash) & nchash])
|
||||
(&nchashtbl[((dvp)->v_id + (cnp)->cn_hash) % nchash])
|
||||
static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */
|
||||
static u_long nchash; /* size of hash table - 1 */
|
||||
static int doingcache = 1; /* 1 => enable the cache */
|
||||
SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, "");
|
||||
static u_long nchash; /* size of hash table */
|
||||
static u_long numcache; /* number of cache entries allocated */
|
||||
static TAILQ_HEAD(, namecache) nclruhead; /* LRU chain */
|
||||
struct nchstats nchstats; /* cache effectiveness statistics */
|
||||
|
||||
static int doingcache = 1; /* 1 => enable the cache */
|
||||
SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, "");
|
||||
|
||||
#ifdef NCH_STATISTICS
|
||||
u_long nchnbr;
|
||||
#define NCHNBR(ncp) (ncp)->nc_nbr = ++nchnbr;
|
||||
@ -144,7 +145,6 @@ cache_lookup(dvp, vpp, cnp)
|
||||
cnp->cn_flags &= ~MAKEENTRY;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (cnp->cn_namelen > NCHNAMLEN) {
|
||||
nchstats.ncs_long++;
|
||||
cnp->cn_flags &= ~MAKEENTRY;
|
||||
@ -225,12 +225,10 @@ cache_enter(dvp, vp, cnp)
|
||||
if (!doingcache)
|
||||
return;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (cnp->cn_namelen > NCHNAMLEN) {
|
||||
printf("cache_enter: name too long");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We allocate a new entry if we are less than the maximum
|
||||
@ -256,6 +254,7 @@ cache_enter(dvp, vp, cnp)
|
||||
/* give up */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in cache info, if vp is NULL this is a "negative" cache entry.
|
||||
* For negative entries, we have to record whether it is a whiteout.
|
||||
@ -284,6 +283,7 @@ cache_enter(dvp, vp, cnp)
|
||||
void
|
||||
nchinit()
|
||||
{
|
||||
|
||||
TAILQ_INIT(&nclruhead);
|
||||
nchashtbl = phashinit(desiredvnodes, M_CACHE, &nchash);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user