diff options
author | Fabian Frederick <fabf@skynet.be> | 2014-05-20 12:50:16 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-05-21 04:26:13 -0400 |
commit | 770901cc1352b46f0e2de08260ec40c0364d7723 (patch) | |
tree | 6f6826ca0773a7dfb765a29efacdef204316fe46 /fs/jbd | |
parent | afd54c6881a51fe9cef843b36d289ae74a8f14bb (diff) |
fs/jbd/revoke.c: replace shift loop by ilog2
journal_init_revoke_table is only called with positive hash_size
(JOURNAL_REVOKE_DEFAULT_HASH) so we can replace loop shift by ilog2
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/jbd')
-rw-r--r-- | fs/jbd/revoke.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c index 25c713e7071c..8898bbd2b61e 100644 --- a/fs/jbd/revoke.c +++ b/fs/jbd/revoke.c | |||
@@ -231,19 +231,15 @@ record_cache_failure: | |||
231 | 231 | ||
232 | static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size) | 232 | static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size) |
233 | { | 233 | { |
234 | int shift = 0; | 234 | int i; |
235 | int tmp = hash_size; | ||
236 | struct jbd_revoke_table_s *table; | 235 | struct jbd_revoke_table_s *table; |
237 | 236 | ||
238 | table = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL); | 237 | table = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL); |
239 | if (!table) | 238 | if (!table) |
240 | goto out; | 239 | goto out; |
241 | 240 | ||
242 | while((tmp >>= 1UL) != 0UL) | ||
243 | shift++; | ||
244 | |||
245 | table->hash_size = hash_size; | 241 | table->hash_size = hash_size; |
246 | table->hash_shift = shift; | 242 | table->hash_shift = ilog2(hash_size); |
247 | table->hash_table = | 243 | table->hash_table = |
248 | kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL); | 244 | kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL); |
249 | if (!table->hash_table) { | 245 | if (!table->hash_table) { |
@@ -252,8 +248,8 @@ static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size) | |||
252 | goto out; | 248 | goto out; |
253 | } | 249 | } |
254 | 250 | ||
255 | for (tmp = 0; tmp < hash_size; tmp++) | 251 | for (i = 0; i < hash_size; i++) |
256 | INIT_LIST_HEAD(&table->hash_table[tmp]); | 252 | INIT_LIST_HEAD(&table->hash_table[i]); |
257 | 253 | ||
258 | out: | 254 | out: |
259 | return table; | 255 | return table; |