From: Heinz Mauelshagen <heinzm@xxxxxxxxxx> 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 <lzhong@xxxxxxxx> Signed-off-by: Heinz Mauelshagen <heinzm@xxxxxxxxxx> --- drivers/md/dm-raid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 4880b69..595afd5 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -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 { /* -- 1.9.3 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel