summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-11-13 10:59:58 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2015-11-13 11:17:06 +0100
commit007be91e3d128320c290fc404532d1d691212b88 (patch)
tree1cb09d5bbaf1ae0f04beca3ce2893331981387a2
parentd74e1291cd43f50010c22fb2c071d92390a26d28 (diff)
downloadlvm2-007be91e3d128320c290fc404532d1d691212b88.tar.gz
raid: ensure area_count is at least 2
Enusure we will not divide by 0.
-rw-r--r--lib/metadata/raid_manip.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index ee1f2be62..4b2cb610e 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -460,9 +460,14 @@ static int _alloc_image_components(struct logical_volume *lv,
* individual devies, we must specify how large the individual device
* 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 */
- else
+ } else
extents = (segtype->parity_devs) ?
(lv->le_count / (seg->area_count - segtype->parity_devs)) :
lv->le_count;