]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
dm raid: round region_size to power of two
authorJonathan Brassow <jbrassow@redhat.com>
Fri, 21 Dec 2012 20:23:33 +0000 (20:23 +0000)
committerAlasdair G Kergon <agk@redhat.com>
Fri, 21 Dec 2012 20:23:33 +0000 (20:23 +0000)
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>
drivers/md/dm-raid.c

index 45d94a7e7f6db798ce291546f7916b246203f85b..4a20bf8c72da66f81572c6bb65102e994eb4c8e4 100644 (file)
@@ -295,9 +295,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
                 * Choose a reasonable default.  All figures in sectors.
                 */
                if (min_region_size > (1 << 13)) {
+                       /* If not a power of 2, make it the next power of 2 */
+                       if (min_region_size & (min_region_size - 1))
+                               region_size = 1 << fls(region_size);
                        DMINFO("Choosing default region size of %lu sectors",
                               region_size);
-                       region_size = min_region_size;
                } else {
                        DMINFO("Choosing default region size of 4MiB");
                        region_size = 1 << 13; /* sectors */