aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2012-12-21 15:23:33 -0500
committerAlasdair G Kergon <agk@redhat.com>2012-12-21 15:23:33 -0500
commit3a0f9aaee02857609d79b20c809c02a8b7c39d06 (patch)
tree274ae68dfc2d955bb8f9a771388947e947b359b4 /drivers/md
parent2aab38502d0e1bf6cf98183769e35a9ff999dcb1 (diff)
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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-raid.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 45d94a7e7f6d..4a20bf8c72da 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -295,9 +295,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
295 * Choose a reasonable default. All figures in sectors. 295 * Choose a reasonable default. All figures in sectors.
296 */ 296 */
297 if (min_region_size > (1 << 13)) { 297 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);
298 DMINFO("Choosing default region size of %lu sectors", 301 DMINFO("Choosing default region size of %lu sectors",
299 region_size); 302 region_size);
300 region_size = min_region_size;
301 } else { 303 } else {
302 DMINFO("Choosing default region size of 4MiB"); 304 DMINFO("Choosing default region size of 4MiB");
303 region_size = 1 << 13; /* sectors */ 305 region_size = 1 << 13; /* sectors */