master - alloc: Move _calc_area_multiple.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a74e19f80958e0eafeb49ef7a346ba7421b5698 Commit: 4a74e19f80958e0eafeb49ef7a346ba7421b5698 Parent: e773e719109ad54c289f86a54b316e787f0110c8 Author: Alasdair G Kergon <[email protected]> AuthorDate: Thu Sep 24 17:56:19 2015 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Thu Sep 24 17:56:19 2015 +0100
alloc: Move _calc_area_multiple.
--- lib/metadata/lv_manip.c | 90 +++++++++++++++++++++++----------------------- 1 files changed, 45 insertions(+), 45 deletions(-)
lib/metadata/lv_manip.c +45 -45
@@ -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 */