2.4.X inode cache bug
In <[email protected]>, [email protected]
Quoted 11 lines · writes:
Excuse me for the lack of patch in this mail,...
In 2.4.x,linux/fs/inode.chas ahash()function with a small slip-up. The inode hash-value is initialized with "unsigned long tmp =i_ino| ((unsigned long) sb /L1_CACHE_BYTES);". ... I believe this is a
slip-up, because you should NEVER use bitwise-or in a hash formula. This creates a slanted distribution, and depending on the address of the superblock block, can cause severe inefficiency in the code.
Just replacing the | with ^ imroves hash-table efficiency noticeably,...
Then maybe the attached patch is what you want? This also replaces +' on the next line with ^' to avoid slanted distribution.
------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/
fs/inode.c +2 -2
@@ -728,8 +728,8 @@static inline unsigned long hash (struct super_block *sb,unsigned long i_ino) { -unsigned long tmp = i_ino | ((unsigned long ) sb /L1_CACHE_BYTES ); - tmp = tmp + (tmp >>I_HASHBITS ) + (tmp >>I_HASHBITS *2 ); +unsigned long tmp = i_ino ^ ((unsigned long ) sb /L1_CACHE_BYTES ); + tmp = tmp ^ (tmp >>I_HASHBITS ) ^ (tmp >>I_HASHBITS *2 );return tmp &I_HASHMASK ; }