diff --git a/WHATS_NEW b/WHATS_NEW index 91c324eb0..4010e673e 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.119 - ================================== + Fix LV processing with selection to always do the selection on initial state. Version 2.02.118 - 23rd March 2015 ================================== diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c index a975606f9..bbd47c307 100644 --- a/lib/format_text/flags.c +++ b/lib/format_text/flags.c @@ -92,6 +92,7 @@ static const struct flag _lv_flags[] = { {CACHE_POOL_DATA, NULL, 0}, {CACHE_POOL_METADATA, NULL, 0}, {LV_PENDING_DELETE, NULL, 0}, /* FIXME Display like COMPATIBLE_FLAG */ + {LV_REMOVED, NULL, 0}, {0, NULL, 0} }; diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index c9c1145c4..b9cd056d2 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -5338,6 +5338,7 @@ int link_lv_to_vg(struct volume_group *vg, struct logical_volume *lv) lvl->lv = lv; lv->vg = vg; dm_list_add(&vg->lvs, &lvl->list); + lv->status &= ~LV_REMOVED; return 1; } @@ -5350,6 +5351,7 @@ int unlink_lv_from_vg(struct logical_volume *lv) return_0; dm_list_del(&lvl->list); + lv->status |= LV_REMOVED; return 1; } diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 1555c87e3..75cd94f22 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -119,11 +119,18 @@ #define CACHE UINT64_C(0x0001000000000000) /* LV - Internal use only */ #define LV_PENDING_DELETE UINT64_C(0x0004000000000000) /* LV - Internal use only */ +#define LV_REMOVED UINT64_C(0x0040000000000000) /* LV - Internal use only + This flag is used to mark an LV once it has + been removed from the VG. It might still + be referenced on internal lists of LVs. + Any remaining references should check for + this flag and ignore the LV is set. + */ #define LV_ERROR_WHEN_FULL UINT64_C(0x0008000000000000) /* LV - error when full */ #define PV_ALLOCATION_PROHIBITED UINT64_C(0x0010000000000000) /* PV - internal use only - allocation prohibited e.g. to prohibit allocation of a RAID image on a PV already holing an image of the RAID set */ -/* Next unused flag: UINT64_C(0x0040000000000000) */ +/* Next unused flag: UINT64_C(0x0080000000000000) */ /* Format features flags */ #define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */ @@ -222,6 +229,8 @@ #define lv_is_rlog(lv) (((lv)->status & REPLICATOR_LOG) ? 1 : 0) +#define lv_is_removed(lv) (((lv)->status & LV_REMOVED) ? 1 : 0) + int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv, struct dm_list **layout, struct dm_list **role); diff --git a/tools/toollib.c b/tools/toollib.c index 4bd233991..be8945019 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1957,6 +1957,10 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, unsigned lvargs_supplied = 0; struct lv_list *lvl; struct dm_str_list *sl; + struct dm_list final_lvs; + struct lv_list *final_lvl; + + dm_list_init(&final_lvs); if (!vg_check_status(vg, EXPORTED_VG)) { ret_max = ECMD_FAILED; @@ -1986,10 +1990,6 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, (tags_supplied && str_list_match_list(tags_in, &vg->tags, NULL))) process_all = 1; - /* - * FIXME: In case of remove it goes through deleted entries, - * but it works since entries are allocated from vg mem pool. - */ dm_list_iterate_items(lvl, &vg->lvs) { if (sigint_caught()) { ret_max = ECMD_FAILED; @@ -2049,6 +2049,21 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, if (!process_lv) continue; + log_very_verbose("Adding %s/%s to the list of LVs to be processed.", vg->name, lvl->lv->name); + + if (!(final_lvl = dm_pool_zalloc(vg->vgmem, sizeof(struct lv_list)))) { + log_error("Failed to allocate final LV list item."); + ret_max = ECMD_FAILED; + goto_out; + } + final_lvl->lv = lvl->lv; + dm_list_add(&final_lvs, &final_lvl->list); + } + + dm_list_iterate_items(lvl, &final_lvs) { + if (lv_is_removed(lvl->lv)) + continue; + log_very_verbose("Processing LV %s in VG %s.", lvl->lv->name, vg->name); ret = process_single_lv(cmd, lvl->lv, handle);