Commit 8defd830 authored by Robert P. J. Day's avatar Robert P. J. Day Committed by Alasdair G Kergon

dm snapshot: use rounddown_pow_of_two

Since the source file already includes the log2.h header file, it
seems pointless to re-invent the necessary routine.
Signed-off-by: default avatarRobert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 82d601dc
...@@ -333,16 +333,6 @@ static int calc_max_buckets(void) ...@@ -333,16 +333,6 @@ static int calc_max_buckets(void)
return mem; return mem;
} }
/*
* Rounds a number down to a power of 2.
*/
static uint32_t round_down(uint32_t n)
{
while (n & (n - 1))
n &= (n - 1);
return n;
}
/* /*
* Allocate room for a suitable hash table. * Allocate room for a suitable hash table.
*/ */
...@@ -361,8 +351,7 @@ static int init_hash_tables(struct dm_snapshot *s) ...@@ -361,8 +351,7 @@ static int init_hash_tables(struct dm_snapshot *s)
hash_size = min(origin_dev_size, cow_dev_size) >> s->chunk_shift; hash_size = min(origin_dev_size, cow_dev_size) >> s->chunk_shift;
hash_size = min(hash_size, max_buckets); hash_size = min(hash_size, max_buckets);
/* Round it down to a power of 2 */ hash_size = rounddown_pow_of_two(hash_size);
hash_size = round_down(hash_size);
if (init_exception_table(&s->complete, hash_size)) if (init_exception_table(&s->complete, hash_size))
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment