diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 429a48779..02a43b7f2 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1264,6 +1264,51 @@ static int _lv_segment_add_areas(struct logical_volume *lv, return 1; } +static uint32_t _calc_area_multiple(const struct segment_type *segtype, + const uint32_t area_count, + const uint32_t stripes) +{ + if (!area_count) + return 1; + + /* Striped */ + if (segtype_is_striped(segtype)) + return area_count; + + /* Parity RAID (e.g. RAID 4/5/6) */ + if (segtype_is_raid(segtype) && segtype->parity_devs) { + /* + * As articulated in _alloc_init, we can tell by + * the area_count whether a replacement drive is + * being allocated; and if this is the case, then + * there is no area_multiple that should be used. + */ + if (area_count <= segtype->parity_devs) + return 1; + + return area_count - segtype->parity_devs; + } + + /* + * RAID10 - only has 2-way mirror right now. + * If we are to move beyond 2-way RAID10, then + * the 'stripes' argument will always need to + * be given. + */ + if (!strcmp(segtype->name, _lv_type_names[LV_TYPE_RAID10])) { + if (!stripes) + return area_count / 2; + return stripes; + } + + /* Mirrored stripes */ + if (stripes) + return stripes; + + /* Mirrored */ + return 1; +} + /* * Reduce the size of an lv_segment. New size can be zero. */ @@ -1519,51 +1564,6 @@ struct alloc_handle { struct dm_list alloced_areas[0]; }; -static uint32_t _calc_area_multiple(const struct segment_type *segtype, - const uint32_t area_count, - const uint32_t stripes) -{ - if (!area_count) - return 1; - - /* Striped */ - if (segtype_is_striped(segtype)) - return area_count; - - /* Parity RAID (e.g. RAID 4/5/6) */ - if (segtype_is_raid(segtype) && segtype->parity_devs) { - /* - * As articulated in _alloc_init, we can tell by - * the area_count whether a replacement drive is - * being allocated; and if this is the case, then - * there is no area_multiple that should be used. - */ - if (area_count <= segtype->parity_devs) - return 1; - - return area_count - segtype->parity_devs; - } - - /* - * RAID10 - only has 2-way mirror right now. - * If we are to move beyond 2-way RAID10, then - * the 'stripes' argument will always need to - * be given. - */ - if (!strcmp(segtype->name, _lv_type_names[LV_TYPE_RAID10])) { - if (!stripes) - return area_count / 2; - return stripes; - } - - /* Mirrored stripes */ - if (stripes) - return stripes; - - /* Mirrored */ - return 1; -} - /* * Returns log device size in extents, algorithm from kernel code */