--- inode/fs/inode.c.~1~ Tue Oct 24 03:27:15 2000 +++ inode/fs/inode.c Tue Oct 24 04:28:43 2000 @@ -11,6 +11,7 @@ #include #include #include +#include /* * New inode.c implementation. @@ -29,9 +29,8 @@ * Inode lookup is no longer as critical as it used to be: * most of the lookups are going to be through the dcache. */ -#define HASH_BITS 8 -#define HASH_SIZE (1UL << HASH_BITS) -#define HASH_MASK (HASH_SIZE-1) +#define HASH_BITS i_hash_bits +#define HASH_MASK i_hash_mask /* * Each inode can be on two separate lists. One is @@ -47,7 +46,9 @@ LIST_HEAD(inode_in_use); static LIST_HEAD(inode_unused); -static struct list_head inode_hashtable[HASH_SIZE]; +static unsigned int i_hash_bits; +static unsigned int i_hash_mask; +static struct list_head *inode_hashtable; __u32 inode_generation_count = 0; @@ -835,29 +836,52 @@ return 0; } -/* - * Initialize the hash tables and default - * value for max inodes - */ -#define MAX_INODE (16384) - void __init inode_init(void) { - int i, max; - struct list_head *head = inode_hashtable; + int i, order; + struct list_head *d; + unsigned int nr_hash; + unsigned long memory_size; + +#ifndef CONFIG_BIGMEM + memory_size = num_physpages << PAGE_SHIFT; +#else + memory_size = bigmem_mapnr << PAGE_SHIFT; +#endif + 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); + i_hash_mask = (nr_hash - 1); + + tmp = nr_hash; + i_hash_bits = 0; + while((tmp >>= 1UL) != 0UL) + i_hash_bits++; + + inode_hashtable = (struct list_head *) + __get_free_pages(GFP_ATOMIC, order); + } while(inode_hashtable == NULL && --order >= 0); + printk("Inode hash table entries: %d (order %d, %ldk)\n", + nr_hash, order, (1UL<> 1; - if (max > MAX_INODE) - max = MAX_INODE; - max_inodes = max; + max_inodes = nr_hash; /* Get a random number. */ get_random_bytes (&inode_generation_count,