From 07b6174f7cb3ac70df2791d54f654d6d5ca36169 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 22 Aug 2024 14:27:10 +0200 Subject: [PATCH] validation: support empty lv segments Revert 373372c8ab3749bc76ced37cec04b00aae6e5979 and instead update our validation code to handle LVs with empty segment - currently we should need this only for pvmove operation, thus such LV should have name 'pvmove%u'. This fixes a problem where user tried i.e. pvmove on a VG with single PV - as reported: https://github.com/lvmteam/lvm2/issues/148 Reported-by: bob@redhat.com --- lib/metadata/lv_manip.c | 10 ---------- lib/metadata/merge.c | 8 ++++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 6252c4469..cb77ee77e 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -8654,19 +8654,9 @@ 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++) { diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index 25b2bc33a..2b1d48dc1 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -744,8 +744,12 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) } if (!le) { - log_error("LV %s: has no segment.", lv->name); - inc_error_count; + if (sscanf(lv->name, "pvmove%u", &le) == 1) + log_debug("LV pvmove %s has no segment.", lv->name); + else { + log_error("LV %s: has no segment.", lv->name); + inc_error_count; + } } dm_list_iterate_items(sl, &lv->segs_using_this_lv) {