Skip to content

Commit

Permalink
fs/jbd/revoke.c: replace shift loop by ilog2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fabian Frederick authored and Jan Kara committed May 21, 2014
1 parent afd54c6 commit 770901c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions fs/jbd/revoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,15 @@ int __init journal_init_revoke_caches(void)

static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size)
{
int shift = 0;
int tmp = hash_size;
int i;
struct jbd_revoke_table_s *table;

table = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL);
if (!table)
goto out;

while((tmp >>= 1UL) != 0UL)
shift++;

table->hash_size = hash_size;
table->hash_shift = shift;
table->hash_shift = ilog2(hash_size);
table->hash_table =
kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
if (!table->hash_table) {
Expand All @@ -252,8 +248,8 @@ static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size)
goto out;
}

for (tmp = 0; tmp < hash_size; tmp++)
INIT_LIST_HEAD(&table->hash_table[tmp]);
for (i = 0; i < hash_size; i++)
INIT_LIST_HEAD(&table->hash_table[i]);

out:
return table;
Expand Down

0 comments on commit 770901c

Please sign in to comment.