1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-04 09:18:36 +03:00

Call add_pvl_to_vgs() and del_pvl_from_vgs() from more places.

Now that we have library functions to add/delete a pv from the vg->pvs
list, call them from everywhere.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
Dave Wysochanski 2010-04-13 17:26:03 +00:00
parent 8cfd64de78
commit 0adfbfd5ea
5 changed files with 12 additions and 23 deletions

View File

@ -119,8 +119,7 @@ int import_pool_pvs(const struct format_type *fmt, struct volume_group *vg,
pl->pv = pvl->pv; pl->pv = pvl->pv;
pvl->mdas = NULL; pvl->mdas = NULL;
pvl->pe_ranges = NULL; pvl->pe_ranges = NULL;
vg->pv_count++; add_pvl_to_vgs(vg, pvl);
dm_list_add(&vg->pvs, &pvl->list);
} }
return 1; return 1;

View File

@ -347,10 +347,8 @@ int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
_vg_bad_status_bits(vg_to, RESIZEABLE_VG)) _vg_bad_status_bits(vg_to, RESIZEABLE_VG))
return 0; return 0;
dm_list_move(&vg_to->pvs, &pvl->list); del_pvl_from_vgs(vg_from, pvl);
add_pvl_to_vgs(vg_to, pvl);
vg_from->pv_count--;
vg_to->pv_count++;
pv = pvl->pv; pv = pvl->pv;
@ -517,7 +515,7 @@ int vg_remove_check(struct volume_group *vg)
return 0; return 0;
dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs) { dm_list_iterate_items_safe(pvl, tpvl, &vg->pvs) {
dm_list_del(&pvl->list); del_pvl_from_vgs(vg, pvl);
dm_list_add(&vg->removed_pvs, &pvl->list); dm_list_add(&vg->removed_pvs, &pvl->list);
} }
return 1; return 1;
@ -2510,8 +2508,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
goto bad; goto bad;
} }
pvl->pv = pv; pvl->pv = pv;
dm_list_add(&vg->pvs, &pvl->list); add_pvl_to_vgs(vg, pvl);
vg->pv_count++;
} }
return vg; return vg;

View File

@ -751,8 +751,7 @@ static void _remove_missing_empty_pv(struct volume_group *vg, struct dm_list *re
/* FIXME: duplication of vgreduce code, move this to library */ /* FIXME: duplication of vgreduce code, move this to library */
vg->free_count -= pvl_vg->pv->pe_count; vg->free_count -= pvl_vg->pv->pe_count;
vg->extent_count -= pvl_vg->pv->pe_count; vg->extent_count -= pvl_vg->pv->pe_count;
vg->pv_count--; del_pvl_from_vgs(vg, pvl_vg);
dm_list_del(&pvl_vg->list);
removed++; removed++;
} }

View File

@ -31,6 +31,7 @@ static struct volume_group *_vgmerge_vg_read(struct cmd_context *cmd,
static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
const char *vg_name_from) const char *vg_name_from)
{ {
struct pv_list *pvl, *tpvl;
struct volume_group *vg_to, *vg_from; struct volume_group *vg_to, *vg_from;
struct lv_list *lvl1, *lvl2; struct lv_list *lvl1, *lvl2;
int r = ECMD_FAILED; int r = ECMD_FAILED;
@ -82,16 +83,11 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
drop_cached_metadata(vg_from); drop_cached_metadata(vg_from);
/* Merge volume groups */ /* Merge volume groups */
while (!dm_list_empty(&vg_from->pvs)) { dm_list_iterate_items_safe(pvl, tpvl, &vg_from->pvs) {
struct dm_list *pvh = vg_from->pvs.n; del_pvl_from_vgs(vg_from, pvl);
struct physical_volume *pv; add_pvl_to_vgs(vg_to, pvl);
pvl->pv->vg_name = dm_pool_strdup(cmd->mem, vg_to->name);
dm_list_move(&vg_to->pvs, pvh);
pv = dm_list_item(pvh, struct pv_list)->pv;
pv->vg_name = dm_pool_strdup(cmd->mem, vg_to->name);
} }
vg_to->pv_count += vg_from->pv_count;
/* Fix up LVIDs */ /* Fix up LVIDs */
dm_list_iterate_items(lvl1, &vg_to->lvs) { dm_list_iterate_items(lvl1, &vg_to->lvs) {

View File

@ -39,9 +39,7 @@ static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)
vg->free_count -= pvl->pv->pe_count; vg->free_count -= pvl->pv->pe_count;
vg->extent_count -= pvl->pv->pe_count; vg->extent_count -= pvl->pv->pe_count;
vg->pv_count--; del_pvl_from_vgs(vg, pvl);
dm_list_del(&pvl->list);
return 1; return 1;
} }