diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2015-10-28 18:40:48 +0100 |
---|---|---|
committer | Heinz Mauelshagen <heinzm@redhat.com> | 2015-10-28 18:40:48 +0100 |
commit | c4314a0ff2e443774d1def7f110e563501644126 (patch) | |
tree | 2d6a26f563dd7ff62f122bb42c8ff79f608cc2ef | |
parent | 965a163140f4808f80c50d3bb35071413a021f57 (diff) | |
download | lvm2-c4314a0ff2e443774d1def7f110e563501644126.tar.gz |
raid_manip: fix false _raid_conv_unduplicate arguments
cleanup
lv_manip: cleanup
-rw-r--r-- | lib/metadata/lv_manip.c | 17 | ||||
-rw-r--r-- | lib/metadata/raid_manip.c | 44 |
2 files changed, 13 insertions, 48 deletions
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 36daf053c..78615fe41 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1391,7 +1391,7 @@ PFL(); /* Return 1 in case any last segment of @lv, area @s contains another layered LV */ /* HM FIXME: correct? */ -static int _is_multilayered_lv(struct logical_volume *lv, uint32_t s) +static int _is_layered_lv(struct logical_volume *lv, uint32_t s) { struct lv_segment *seg = last_seg(lv), *seg1; @@ -1400,12 +1400,6 @@ static int _is_multilayered_lv(struct logical_volume *lv, uint32_t s) seg_type(seg, s) == AREA_LV && (seg1 = last_seg(seg_lv(seg, s))) && !seg_is_striped(seg1); -#if 0 - && /* <- segment of #s LV underneath top-level */ - seg_type(seg1, 0) == AREA_LV && - (strstr(seg_lv(seg1, 0)->name, "_rimage") || - strstr(seg_lv(seg1, 0)->name, "_rdimage")); -#endif } /* @@ -1428,7 +1422,7 @@ PFLA("lv=%s lv->le_count=%u seg=%p extents=%u stripes=%u data_copies=%u delete=% /* Check for multi-level stack (e.g. reduction of a duplicated LV stack) */ if (!dont_recurse) { for (s = 0; s < seg->area_count; s++) { - if (_is_multilayered_lv(lv, s)) { + if (_is_layered_lv(lv, s)) { uint32_t seg_lv_extents = seg_lv(seg, s)->le_count; if (!delete) @@ -4346,18 +4340,19 @@ int lv_extend(struct logical_volume *lv, struct lv_segment *seg = last_seg(lv); log_very_verbose("Adding segment of type %s to LV %s.", segtype->name, display_lvname(lv)); +PFLA("extents=%u", extents); #if 1 /* Check for multi-level stack (e.g. extension of a duplicated LV stack) */ if (seg) { int extended = 0; for (s = 0; s < seg->area_count; s++) { - if (_is_multilayered_lv(lv, s)) { + if (_is_layered_lv(lv, s)) { struct logical_volume *lv1 = seg_lv(seg, s); struct lv_segment *seg1 = last_seg(lv1); -PFLA("recursive seg_lv(seg, %u)=%s", s, display_lvname(lv1)); - if (extents > lv1->le_count && +PFLA("recursive seg_lv(seg, %u)=%s extents=%u", s, display_lvname(lv1), extents); + if (extents + lv->le_count > lv1->le_count && !lv_extend(lv1, seg1->segtype, seg1->area_count, seg1->stripe_size, seg1->data_copies, seg1->region_size, extents, allocatable_pvs, alloc, approx_alloc)) return_0; diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 2c63fed7a..dc7600276 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -177,17 +177,18 @@ uint32_t lv_raid_image_count(const struct logical_volume *lv) return seg_is_raid(seg) ? seg->area_count : 1; } -/* Calculate raid rimage length based on total @extents for segment and @stripes and @data_copies */ +/* Calculate raid rimage length based on total @extents for @segtype, @stripes and @data_copies */ uint32_t lv_raid_rimage_extents(const struct segment_type *segtype, uint32_t extents, uint32_t stripes, uint32_t data_copies) { uint64_t r = extents; - if (segtype_is_raid1(segtype)) + if (!segtype_is_raid(segtype) || + segtype_is_raid1(segtype)) return extents; if (segtype_is_any_raid10(segtype)) - r *= data_copies; + r *= data_copies ?: 1; r = dm_div_up(r, stripes ?: 1); @@ -4815,39 +4816,9 @@ PFL(); } PFLA("segtype=%s image_count=%u stripes=%u stripe_size=%u datacopies=%u", segtype ? segtype->name : NULL, image_count, stripes, stripe_size, data_copies); -#if 0 - /* Find sublv to keep based on segment type */ - keep_idx = seg->area_count + 1; - for (s = 0; s < seg->area_count; s++) { - if (first_seg(seg_lv(seg, s))->segtype == segtype) { - segtype_count++; - keep_idx = s; - seg0 = first_seg(seg_lv(seg, s)); -PFLA("keep_idx=%u", keep_idx); - } - } - - /* If segtype isn't unique -> select again */ - if (segtype_count > 1) - keep_idx = seg->area_count + 1; - - for (s = 0; s < seg->area_count - 1; s++) { - seg0 = first_seg(seg_lv(seg, s)); -PFLA("seg0->segtype=%s seg0->area_count=%u seg0->stripe_size=%u seg0->datacopies=%u", lvseg_name(seg0), seg0->area_count, seg0->stripe_size, seg0->data_copies); - if (segtype == seg0->segtype && - (stripes ? (stripes == _data_rimages_count(seg0, seg0->area_count)) : 1) && - (stripe_size ? (stripe_size == seg0->stripe_size) : 1) && - (data_copies > 1 ? (data_copies == seg0->data_copies) : 1)) { - sub_lv_count++; - keep_idx = s; -PFLA("keep_idx=%u", keep_idx); - } - } - -#else if (segtype) { /* Find sublv to keep based on passed in segment properties */ - for (s = 0; s < seg->area_count - 1; s++) { + for (s = 0; s < seg->area_count; s++) { seg0 = first_seg(seg_lv(seg, s)); PFLA("seg0->segtype=%s seg0->area_count=%u seg0->stripe_size=%u seg0->datacopies=%u", lvseg_name(seg0), seg0->area_count, seg0->stripe_size, seg0->data_copies); if (_seg_meets_properties(first_seg(seg_lv(seg, s)), segtype, @@ -4857,7 +4828,6 @@ PFLA("seg0->segtype=%s seg0->area_count=%u seg0->stripe_size=%u seg0->datacopies PFLA("keep_idx=%u", keep_idx); } } -#endif if (!sub_lv_count) { log_error("Wrong raid type %s/stripes=%u/mirrors=%u requested to remove duplicating conversion", @@ -7166,8 +7136,8 @@ PFLA("new_segtype=%s new_image_count=%u new_stripes=%u stripes=%u", new_segtype */ if (unduplicate) { if (_lv_is_duplicating(lv)) { - if (!_raid_conv_unduplicate(lv, new_segtype, image_count, - stripes, stripe_size, data_copies, yes)) { + if (!_raid_conv_unduplicate(lv, new_segtype, new_image_count, + new_stripes, new_stripe_size, new_data_copies, yes)) { if (!_lv_is_duplicating(lv)) _log_possible_conversion_types(lv, new_segtype); |