[lvm-devel] master - raid: ensure area_count is at least 2
Zdenek Kabelac
zkabelac at fedoraproject.org
Fri Nov 13 10:19:06 UTC 2015
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=007be91e3d128320c290fc404532d1d691212b88
Commit: 007be91e3d128320c290fc404532d1d691212b88
Parent: d74e1291cd43f50010c22fb2c071d92390a26d28
Author: Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate: Fri Nov 13 10:59:58 2015 +0100
Committer: Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Fri Nov 13 11:17:06 2015 +0100
raid: ensure area_count is at least 2
Enusure we will not divide by 0.
---
lib/metadata/raid_manip.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index ee1f2be..4b2cb61 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;
More information about the lvm-devel
mailing list