Code cleanup for hash bits calculation by calling rounddown_pow_of_two() and ilog2()
Signed-off-by: Chengguang Xu <cgxu...@zoho.com.cn> --- fs/quota/dquot.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 6e826b454082..679dd3b5db70 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2983,13 +2983,9 @@ static int __init dquot_init(void) /* Find power-of-two hlist_heads which can fit into allocation */ nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head); - dq_hash_bits = 0; - do { - dq_hash_bits++; - } while (nr_hash >> dq_hash_bits); - dq_hash_bits--; + nr_hash = rounddown_pow_of_two(nr_hash); + dq_hash_bits = ilog2(nr_hash); - nr_hash = 1UL << dq_hash_bits; dq_hash_mask = nr_hash - 1; for (i = 0; i < nr_hash; i++) INIT_HLIST_HEAD(dquot_hash + i); -- 2.21.0