History

fs, jbd: use a more generic hash function

While the hash function used by the revoke hashtable is good somewhere else, it's not really good here. The default hash shift (8) means that one third of the hashing function gets lost (and is undefined anyways (8 - 12 = negative shift)): "(block << (hash_shift - 12))) & (table->hash_size - 1)" Instead, just use the kernel's generic hash function that gets used everywhere else.

Sasha Levin committed 12 years ago

Commit 3c9cafe1 parent 474d2601 file · +2 −5Browse files

Unified · Split

fs/jbd/revoke.c+2−5
@@ -93,6 +93,7 @@ · 92 unmodified lines
9393 #include <linux/bio.h>
9494 #endif
9595 #include <linux/log2.h>
96+#include <linux/hash.h>
9697
9798 static struct kmem_cache *revoke_record_cache;
9899 static struct kmem_cache *revoke_table_cache;
@@ -129,15 +130,11 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int); · 30 unmodified lines
129130
130131 /* Utility functions to maintain the revoke table */
131132
132−/* Borrowed from buffer.c: this is a tried and tested block hash function */
133133 static inline int hash(journal_t *journal, unsigned int block)
134134 {
135135 struct jbd_revoke_table_s *table = journal->j_revoke;
136− int hash_shift = table->hash_shift;
137136
138− return ((block << (hash_shift - 6)) ^
139− (block >> 13) ^
140− (block << (hash_shift - 12))) & (table->hash_size - 1);
137+ return hash_32(block, table->hash_shift);
141138 }
142139
143140 static int insert_revoke_hash(journal_t *journal, unsigned int blocknr,