From 6a182bf33878542157430c6ffb32bebbeb255d70 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Thu, 4 Feb 2016 14:28:58 +0100 Subject: [PATCH] raid_manip: fix data copies on mirror <-> raid1 conversions --- lib/metadata/lv_manip.c | 6 ++++-- lib/metadata/raid_manip.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 616ef0476..5df10180c 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -4452,6 +4452,9 @@ int lv_extend(struct logical_volume *lv, return 0; } + if (segtype_is_mirrored(segtype) || segtype_is_raid1(segtype)) + stripes = 1; + log_very_verbose("Adding segment of type %s to LV %s.", segtype->name, display_lvname(lv)); PFLA("extents=%u", extents); #if 1 @@ -5686,8 +5689,7 @@ PFL(); #if 1 /* HM FIXME: sufficient for RAID? */ - if (seg_is_raid(seg) && - !seg_is_raid1(seg)) { + if (seg_is_striped_raid(seg)) { unsigned stripes = seg->area_count - seg->segtype->parity_devs; lp->extents = _round_to_stripe_boundary(lv, lp->extents, stripes, diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 09eff68b3..563064280 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -3731,6 +3731,7 @@ static int _convert_mirror_to_raid(struct logical_volume *lv, init_mirror_in_sync(1); seg->segtype = new_segtype; + seg->data_copies = new_image_count; lv->status &= ~(MIRROR | MIRRORED); lv->status |= RAID; seg->status |= RAID; @@ -3805,6 +3806,7 @@ static int _convert_raid1_to_mirror(struct logical_volume *lv, seg->segtype = new_segtype; seg->region_size = new_region_size; + seg->data_copies = new_image_count; lv->status &= ~RAID; seg->status &= ~RAID; lv->status |= (MIRROR | MIRRORED);