From a09a8efb66e28492f680017015181d9f91b5a993 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Mon, 28 Jun 2010 20:38:56 +0000 Subject: [PATCH] Update check in vg_split_mdas to account for ignored mdas list. The check in vg_split_mdas will trigger an error if the 'from' vg list is empty. However, this might be ok in some instances now that we have ignored mdas. Relax this check so an error is triggered only in the case where there's truly no more mdas in the 'from' vg. One example of where this makes a difference is with vgreduce. If we try to vgreduce a PV with un-ignored mdas, this should trigger the balancing function to un-ignore mdas on another PV in the VG. However, we don't get to vg_write() before we fail because this list size check fails, and we see an error message indicating: "Cannot remove final metadata area ..." Another example is with vgsplit into a new VG, where the PVs being moved contain all ignored mdas. We must move the mdas on fid->metadata_areas_ignored from 'vg_from' to 'vg_to'. Signed-off-by: Dave Wysochanski --- lib/metadata/metadata.c | 42 +++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 1ba7867c8..d17bf742d 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -1366,20 +1366,12 @@ int vg_set_clustered(struct volume_group *vg, int clustered) return 1; } -/* - * Separate metadata areas after splitting a VG. - * Also accepts orphan VG as destination (for vgreduce). - */ -int vg_split_mdas(struct cmd_context *cmd __attribute((unused)), - struct volume_group *vg_from, struct volume_group *vg_to) +static int _move_mdas(struct volume_group *vg_from, struct volume_group *vg_to, + struct dm_list *mdas_from, struct dm_list *mdas_to) { struct metadata_area *mda, *mda2; - struct dm_list *mdas_from, *mdas_to; int common_mda = 0; - mdas_from = &vg_from->fid->metadata_areas_in_use; - mdas_to = &vg_to->fid->metadata_areas_in_use; - dm_list_iterate_items_safe(mda, mda2, mdas_from) { if (!mda->ops->mda_in_vg) { common_mda = 1; @@ -1393,9 +1385,35 @@ int vg_split_mdas(struct cmd_context *cmd __attribute((unused)), dm_list_move(mdas_to, &mda->list); } } + return common_mda; +} + +/* + * Separate metadata areas after splitting a VG. + * Also accepts orphan VG as destination (for vgreduce). + */ +int vg_split_mdas(struct cmd_context *cmd __attribute((unused)), + struct volume_group *vg_from, struct volume_group *vg_to) +{ + struct dm_list *mdas_from_in_use, *mdas_to_in_use; + struct dm_list *mdas_from_ignored, *mdas_to_ignored; + int common_mda = 0; - if (dm_list_empty(mdas_from) || - (!is_orphan_vg(vg_to->name) && dm_list_empty(mdas_to))) + mdas_from_in_use = &vg_from->fid->metadata_areas_in_use; + mdas_from_ignored = &vg_from->fid->metadata_areas_ignored; + mdas_to_in_use = &vg_to->fid->metadata_areas_in_use; + mdas_to_ignored = &vg_to->fid->metadata_areas_ignored; + + common_mda = _move_mdas(vg_from, vg_to, + mdas_from_in_use, mdas_to_in_use); + common_mda = _move_mdas(vg_from, vg_to, + mdas_from_ignored, mdas_to_ignored); + + if ((dm_list_empty(mdas_from_in_use) && + dm_list_empty(mdas_from_ignored)) || + ((!is_orphan_vg(vg_to->name) && + dm_list_empty(mdas_to_in_use) && + dm_list_empty(mdas_to_ignored)))) return common_mda; return 1; -- 2.43.5