diff -urN linux-2.4.17-rc2-virgin/fs/buffer.c linux-2.4.17-rc2-wli2/fs/buffer.c --- linux-2.4.17-rc2-virgin/fs/buffer.c Tue Dec 18 23:18:03 2001 +++ linux-2.4.17-rc2-wli2/fs/buffer.c Thu Dec 20 18:43:51 2001 @@ -467,13 +464,25 @@ return err; } -/* After several hours of tedious analysis, the following hash - * function won. Do not mess with it... -DaveM +/* + * The shift/add buffer cache hash function from Chuck Lever's paper. + * http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf + * page 6 describes the behavior of various buffer cache hashes. + * + * The lack of an attempt to mix the bits of dev in this hash + * function appears disturbing to me, but I don't have the + * resources to investigate the value of attempting to do so. + * + * Changed to Lever's multiplicative hash function. + * -- wli */ -#define _hashfn(dev,block) \ - ((((dev)<<(bh_hash_shift - 6)) ^ ((dev)<<(bh_hash_shift - 9))) ^ \ - (((block)<<(bh_hash_shift - 6)) ^ ((block) >> 13) ^ \ - ((block) << (bh_hash_shift - 12)))) + +static inline unsigned long _hashfn(unsigned long dev, unsigned long block) +{ + return ((dev + block) * 2654435761UL) + >> (BITS_PER_LONG - bh_hash_shift); +} + #define hash(dev,block) hash_table[(_hashfn(HASHDEV(dev),block) & bh_hash_mask)] static inline void __insert_into_hash_list(struct buffer_head *bh)