diff options
author | Dave Wysochanski <dwysocha@redhat.com> | 2010-06-30 18:03:52 +0000 |
---|---|---|
committer | Dave Wysochanski <dwysocha@redhat.com> | 2010-06-30 18:03:52 +0000 |
commit | 40b4d1c3ae32fa24b5f034ba9c2e39c9e31d35a1 (patch) | |
tree | d26fc71d67e10f02a55a89148f78db055237cfbf | |
parent | 23177eda88d4f0f1e6ab8c43ced751aa441e47b4 (diff) | |
download | lvm2-40b4d1c3ae32fa24b5f034ba9c2e39c9e31d35a1.tar.gz lvm2-40b4d1c3ae32fa24b5f034ba9c2e39c9e31d35a1.tar.xz lvm2-40b4d1c3ae32fa24b5f034ba9c2e39c9e31d35a1.zip |
Refactor vg_remove_check to place pv removal into separate function.
-rw-r--r-- | lib/metadata/metadata-exported.h | 1 | ||||
-rw-r--r-- | lib/metadata/metadata.c | 9 | ||||
-rw-r--r-- | liblvm/lvm_vg.c | 2 | ||||
-rw-r--r-- | 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 89a0f6a4..8d0f744d 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 0b7063d2..b9982190 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 ada40707..20aeb4f3 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 56e18ef0..ce033475 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; |