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>
This commit is contained in:
committed by
Jan Kara
parent
afd54c6881
commit
770901cc13
@@ -231,19 +231,15 @@ record_cache_failure:
|
|||||||
|
|
||||||
static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size)
|
static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size)
|
||||||
{
|
{
|
||||||
int shift = 0;
|
int i;
|
||||||
int tmp = hash_size;
|
|
||||||
struct jbd_revoke_table_s *table;
|
struct jbd_revoke_table_s *table;
|
||||||
|
|
||||||
table = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL);
|
table = kmem_cache_alloc(revoke_table_cache, GFP_KERNEL);
|
||||||
if (!table)
|
if (!table)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
while((tmp >>= 1UL) != 0UL)
|
|
||||||
shift++;
|
|
||||||
|
|
||||||
table->hash_size = hash_size;
|
table->hash_size = hash_size;
|
||||||
table->hash_shift = shift;
|
table->hash_shift = ilog2(hash_size);
|
||||||
table->hash_table =
|
table->hash_table =
|
||||||
kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
|
kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
|
||||||
if (!table->hash_table) {
|
if (!table->hash_table) {
|
||||||
@@ -252,8 +248,8 @@ static struct jbd_revoke_table_s *journal_init_revoke_table(int hash_size)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = 0; tmp < hash_size; tmp++)
|
for (i = 0; i < hash_size; i++)
|
||||||
INIT_LIST_HEAD(&table->hash_table[tmp]);
|
INIT_LIST_HEAD(&table->hash_table[i]);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return table;
|
return table;
|
||||||
|
Reference in New Issue
Block a user