From 373372c8ab3749bc76ced37cec04b00aae6e5979 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 1 Nov 2017 00:51:39 +0100 Subject: [PATCH] lv_manip: hide layered LV temporarily Since vg_validate() now rejects LVs without segments and insert_layer_for_segments_on_pv() gets just created 'layer_lv' without segment, it needs to be hidden from vg->lvs during processing of _align_segment_boundary_to_pe_range() as this function calls lv_validate() and now requires vg to be consistent. LV is then put back into vg->lvs. --- lib/metadata/lv_manip.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index f0e492bcf..c4c2fdfe4 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -7054,9 +7054,19 @@ int insert_layer_for_segments_on_pv(struct cmd_context *cmd, layer_lv->name, lv_where->name, pvl ? pv_dev_name(pvl->pv) : "any"); + /* Temporarily hide layer_lv from vg->lvs list + * so the lv_split_segment() passes vg_validate() + * since here layer_lv has empty segment list */ + if (!(lvl = find_lv_in_vg(lv_where->vg, layer_lv->name))) + return_0; + dm_list_del(&lvl->list); + if (!_align_segment_boundary_to_pe_range(lv_where, pvl)) return_0; + /* Put back layer_lv in vg->lv */ + dm_list_add(&lv_where->vg->lvs, &lvl->list); + /* Work through all segments on the supplied PV */ dm_list_iterate_items(seg, &lv_where->segments) { for (s = 0; s < seg->area_count; s++) {