Commit 8a0d1a56 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Luis Henriques

dm raid: fix round up of default region size

commit 042745ee upstream.

Commit 3a0f9aae ("dm raid: round region_size to power of two")
intended to make sure that the default region size is a power of two.
However, the logic in that commit is incorrect and sets the variable
region_size to 0 or 1, depending on whether min_region_size is a power
of two.

Fix this logic, using roundup_pow_of_two(), so that region_size is
properly rounded up to the next power of two.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Fixes: 3a0f9aae ("dm raid: round region_size to power of two")
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 68b4506d
...@@ -325,8 +325,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size) ...@@ -325,8 +325,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
*/ */
if (min_region_size > (1 << 13)) { if (min_region_size > (1 << 13)) {
/* If not a power of 2, make it the next power of 2 */ /* If not a power of 2, make it the next power of 2 */
if (min_region_size & (min_region_size - 1)) region_size = roundup_pow_of_two(min_region_size);
region_size = 1 << fls(region_size);
DMINFO("Choosing default region size of %lu sectors", DMINFO("Choosing default region size of %lu sectors",
region_size); region_size);
} else { } else {
......
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