dm-raid: fix bug when round up region_size v2
PATCH 1/1 dm-raid: fix bug when round up region_size v2
From: Heinz Mauelshagen <[email protected]>
If region_size is not supplied by userspace and the device is very large, there is a bug in current code preventing region_size from being correctly set.
This new version uses roundup_pow_of_two() for optimization as proposed by Neil Brown.
Signed-off-by Lidong Zhong <[email protected]>
Signed-off-by Heinz Mauelshagen <[email protected]>
--- drivers/md/dm-raid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/md/dm-raid.c +4 -5
@@ -7,6 +7,7 @@#include <linux/slab.h> #include <linux/module.h> +#include <linux/log2.h> #include "md.h" #include "raid1.h"
@@ -325,13 +326,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)*/ 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 =roundup_pow_of_two (min_region_size); +DMINFO ("Choosing region size of %lu sectors" , region_size); }else { -DMINFO ("Choosing default region size of 4MiB" ); region_size =1 <<13 ;/* sectors */ +DMINFO ("Choosing default region size of 4MiB" ); } }else {/*
Signature · 1 line
1.9.3