diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2014-10-21 16:43:55 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-10-22 04:02:04 -0400 |
commit | 3c9cafe05ff002eb84d438a02f3c8d468720463b (patch) | |
tree | cf3d905c079b6e2f8b00d97523c8b4cdacf8edc1 | |
parent | 474d2605d119479e5aa050f738632e63589d4bb5 (diff) |
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.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/jbd/revoke.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c index 8898bbd2b61e..dcead636c33b 100644 --- a/fs/jbd/revoke.c +++ b/fs/jbd/revoke.c | |||
@@ -93,6 +93,7 @@ | |||
93 | #include <linux/bio.h> | 93 | #include <linux/bio.h> |
94 | #endif | 94 | #endif |
95 | #include <linux/log2.h> | 95 | #include <linux/log2.h> |
96 | #include <linux/hash.h> | ||
96 | 97 | ||
97 | static struct kmem_cache *revoke_record_cache; | 98 | static struct kmem_cache *revoke_record_cache; |
98 | static struct kmem_cache *revoke_table_cache; | 99 | static struct kmem_cache *revoke_table_cache; |
@@ -129,15 +130,11 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int); | |||
129 | 130 | ||
130 | /* Utility functions to maintain the revoke table */ | 131 | /* Utility functions to maintain the revoke table */ |
131 | 132 | ||
132 | /* Borrowed from buffer.c: this is a tried and tested block hash function */ | ||
133 | static inline int hash(journal_t *journal, unsigned int block) | 133 | static inline int hash(journal_t *journal, unsigned int block) |
134 | { | 134 | { |
135 | struct jbd_revoke_table_s *table = journal->j_revoke; | 135 | struct jbd_revoke_table_s *table = journal->j_revoke; |
136 | int hash_shift = table->hash_shift; | ||
137 | 136 | ||
138 | return ((block << (hash_shift - 6)) ^ | 137 | return hash_32(block, table->hash_shift); |
139 | (block >> 13) ^ | ||
140 | (block << (hash_shift - 12))) & (table->hash_size - 1); | ||
141 | } | 138 | } |
142 | 139 | ||
143 | static int insert_revoke_hash(journal_t *journal, unsigned int blocknr, | 140 | static int insert_revoke_hash(journal_t *journal, unsigned int blocknr, |