From 66fff1d7748f8251c8781830fa984f34d1492310 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Thu, 9 Mar 2017 22:18:34 +0100 Subject: [PATCH] raid: add missing lv_merge_segments() call On conversion from striped to raid0, data LVs are created and all segments and their respective areas of the striped LV are moved across to new segments allocated for the raid0 image LVs. This can cause non-canonical segments to be added to the image LVs. Add a call to lv_merge_segments() once all segments have been added to an image LV to compensate for that. This avoids unsafe table loads on activation. Fix comments. --- lib/metadata/raid_manip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 515e4b8d7..09069165a 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -3986,6 +3986,10 @@ static int _striped_to_raid0_move_segs_to_raid0_lvs(struct logical_volume *lv, dlv->le_count = le; dlv->size = (uint64_t) le * lv->vg->extent_size; s++; + + /* Try merging raid0 rimage sub LV segments */ + if (!lv_merge_segments(dlv)) + return_0; } /* Remove the empty segments from the striped LV */ @@ -5122,7 +5126,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS) if (!_lv_free_reshape_space(lv)) return_0; - /* This helper can be used to convert from striped/raid0* -> raid10 too */ + /* This helper can be used to convert from striped/raid0* -> raid10_near too */ if (seg_is_striped_target(seg)) { log_debug_metadata("Converting LV %s from %s to %s.", display_lvname(lv), SEG_TYPE_NAME_STRIPED, SEG_TYPE_NAME_RAID0); @@ -5179,7 +5183,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS) } else if (segtype_is_raid10_near(new_segtype)) { uint32_t s; - log_debug_metadata("Reordering areas for raid0 -> raid10 takeover."); + log_debug_metadata("Reordering areas for raid0 -> raid10_near takeover."); if (!_reorder_raid10_near_seg_areas(seg, reorder_to_raid10_near)) return 0; /* Set rebuild flags accordingly */