From 40b4d1c3ae32fa24b5f034ba9c2e39c9e31d35a1 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Wed, 30 Jun 2010 18:03:52 +0000 Subject: [PATCH] Refactor vg_remove_check to place pv removal into separate function. --- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 9 +++++++-- liblvm/lvm_vg.c | 2 ++ tools/vgremove.c | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 89a0f6a41..8d0f744d9 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -540,6 +540,7 @@ uint32_t pv_list_extents_free(const struct dm_list *pvh); struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name); int vg_remove_mdas(struct volume_group *vg); int vg_remove_check(struct volume_group *vg); +void vg_remove_pvs(struct volume_group *vg); int vg_remove(struct volume_group *vg); int vg_rename(struct cmd_context *cmd, struct volume_group *vg, const char *new_name); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 0b7063d21..b99821900 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -510,7 +510,6 @@ int remove_lvs_in_vg(struct cmd_context *cmd, int vg_remove_check(struct volume_group *vg) { unsigned lv_count; - struct pv_list *pvl, *tpvl; if (vg_read_error(vg) || vg_missing_pv_count(vg)) { log_error("Volume group \"%s\" not found, is inconsistent " @@ -534,11 +533,17 @@ int vg_remove_check(struct volume_group *vg) if (!archive(vg)) return 0; + return 1; +} + +void vg_remove_pvs(struct volume_group *vg) +{ + struct pv_list *pvl, *tpvl; + dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs) { del_pvl_from_vgs(vg, pvl); dm_list_add(&vg->removed_pvs, &pvl->list); } - return 1; } int vg_remove(struct volume_group *vg) diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c index ada407070..20aeb4f33 100644 --- a/liblvm/lvm_vg.c +++ b/liblvm/lvm_vg.c @@ -180,6 +180,8 @@ int lvm_vg_remove(vg_t vg) if (!vg_remove_check(vg)) return -1; + vg_remove_pvs(vg); + return 0; } diff --git a/tools/vgremove.c b/tools/vgremove.c index 56e18ef0b..ce0334754 100644 --- a/tools/vgremove.c +++ b/tools/vgremove.c @@ -54,6 +54,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name, return ECMD_FAILED; } + vg_remove_pvs(vg); + if (!vg_remove(vg)) { stack; return ECMD_FAILED;