1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

raid: ensure area_count is at least 2

Enusure we will not divide by 0.
This commit is contained in:
Zdenek Kabelac 2015-11-13 10:59:58 +01:00
parent d74e1291cd
commit 007be91e3d

View File

@ -460,9 +460,14 @@ static int _alloc_image_components(struct logical_volume *lv,
* individual devies, we must specify how large the individual device * individual devies, we must specify how large the individual device
* is along with the number we want ('count'). * is along with the number we want ('count').
*/ */
if (segtype_is_raid10(segtype)) if (segtype_is_raid10(segtype)) {
if (seg->area_count < 2) {
log_error(INTERNAL_ERROR "LV %s needs at least 2 areas.",
display_lvname(lv));
return 0;
}
extents = lv->le_count / (seg->area_count / 2); /* we enforce 2 mirrors right now */ extents = lv->le_count / (seg->area_count / 2); /* we enforce 2 mirrors right now */
else } else
extents = (segtype->parity_devs) ? extents = (segtype->parity_devs) ?
(lv->le_count / (seg->area_count - segtype->parity_devs)) : (lv->le_count / (seg->area_count - segtype->parity_devs)) :
lv->le_count; lv->le_count;