Skip to content

Commit 3a0f9aa

Browse files
jbrassowkergon
authored andcommitted
dm raid: round region_size to power of two
If the user does not supply a bitmap region_size to the dm raid target, a reasonable size is computed automatically. If this is not a power of 2, the md code will report an error later. This patch catches the problem early and rounds the region_size to the next power of two. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 2aab385 commit 3a0f9aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/md/dm-raid.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
295295
* Choose a reasonable default. All figures in sectors.
296296
*/
297297
if (min_region_size > (1 << 13)) {
298+
/* If not a power of 2, make it the next power of 2 */
299+
if (min_region_size & (min_region_size - 1))
300+
region_size = 1 << fls(region_size);
298301
DMINFO("Choosing default region size of %lu sectors",
299302
region_size);
300-
region_size = min_region_size;
301303
} else {
302304
DMINFO("Choosing default region size of 4MiB");
303305
region_size = 1 << 13; /* sectors */

0 commit comments

Comments
 (0)