提交 3a0f9aae 编写于 作者: J Jonathan Brassow 提交者: Alasdair G Kergon

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: NJonathan Brassow <jbrassow@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 2aab3850
...@@ -295,9 +295,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size) ...@@ -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. * Choose a reasonable default. All figures in sectors.
*/ */
if (min_region_size > (1 << 13)) { 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", DMINFO("Choosing default region size of %lu sectors",
region_size); region_size);
region_size = min_region_size;
} else { } else {
DMINFO("Choosing default region size of 4MiB"); DMINFO("Choosing default region size of 4MiB");
region_size = 1 << 13; /* sectors */ region_size = 1 << 13; /* sectors */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册