diff -urN aa2/fs/dcache.c aa2-dhash/fs/dcache.c --- aa2/fs/dcache.c Tue Oct 26 02:14:07 1999 +++ aa2-dhash/fs/dcache.c Tue Oct 26 02:15:34 1999 @@ -41,11 +41,12 @@ * This hash-function tries to avoid losing too many bits of hash * information, yet avoid using a prime hash-size or similar. */ -#define D_HASHBITS 10 -#define D_HASHSIZE (1UL << D_HASHBITS) -#define D_HASHMASK (D_HASHSIZE-1) +#define D_HASHBITS d_hash_shift +#define D_HASHMASK d_hash_mask -static struct list_head dentry_hashtable[D_HASHSIZE]; +static unsigned int d_hash_mask; +static unsigned int d_hash_shift; +static struct list_head *dentry_hashtable; static LIST_HEAD(dentry_unused); struct { @@ -902,8 +903,10 @@ void __init dcache_init(void) { - int i; - struct list_head *d = dentry_hashtable; + int i, order; + struct list_head *d; + unsigned int nr_hash; + unsigned long memory_size; /* * A constructor could be added for stable state like the lists, @@ -921,7 +924,34 @@ if (!dentry_cache) panic("Cannot create dentry cache"); - i = D_HASHSIZE; + memory_size = num_physpages << PAGE_SHIFT; + memory_size >>= 13; + memory_size *= 2 * sizeof(void *); + for (order = 0; ((1UL << order) << PAGE_SHIFT) < memory_size; order++); + + do { + unsigned long tmp; + + nr_hash = (1UL << order) * PAGE_SIZE / + sizeof(struct list_head); + d_hash_mask = (nr_hash - 1); + + tmp = nr_hash; + d_hash_shift = 0; + while((tmp >>= 1UL) != 0UL) + d_hash_shift++; + + dentry_hashtable = (struct list_head *) + __get_free_pages(GFP_ATOMIC, order); + } while(dentry_hashtable == NULL && --order >= 0); + printk("DENTRY hash table entries: %d (order: %d, %ld bytes)\n", + nr_hash, order, (1UL<