[PATCH] dm raid: fix bug when round up region_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



when region_size is not supplied by userspace and the device is very
large, there is a bug in current code since region_size is not correctly
set.

Signed-off-by: Lidong Zhong <lzhong@xxxxxxxx>
---
 drivers/md/dm-raid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4880b69..ecef01f 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -326,7 +326,9 @@ 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);
+				region_size = 1 << fls(min_region_size);
+			else
+				region_size = min_region_size;
 			DMINFO("Choosing default region size of %lu sectors",
 			       region_size);
 		} else {
-- 
1.8.1.4

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux