From: Dave Wysochanski Date: Tue, 6 Apr 2010 14:04:54 +0000 (+0000) Subject: Add add_pvl_to_vgs() - helper function to add a pv to a vg list. X-Git-Tag: old-v2_02_63~74 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=ae2353caf8e41ccb04edf8cd00d6e7986442a202;p=lvm2.git Add add_pvl_to_vgs() - helper function to add a pv to a vg list. Small refactor of main places in the code where a pv is added to a vg into a small function which adds the pv to the list and updates the vg counts. Signed-off-by: Dave Wysochanski --- diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c index 2ffc19e21..e37d59e73 100644 --- a/lib/format1/import-export.c +++ b/lib/format1/import-export.c @@ -437,8 +437,7 @@ int import_pvs(const struct format_type *fmt, struct dm_pool *mem, return_0; pvl->pv->fmt = fmt; - dm_list_add(&vg->pvs, &pvl->list); - vg->pv_count++; + add_pvl_to_vgs(vg, pvl); } return 1; diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index cf2c9df58..ed508cf9a 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -271,8 +271,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem, vg->extent_count += pv->pe_count; vg->free_count += pv->pe_count; - vg->pv_count++; - dm_list_add(&vg->pvs, &pvl->list); + add_pvl_to_vgs(vg, pvl); return 1; } diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 9e6d9babc..6ceb793fb 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -136,6 +136,13 @@ out: return pv->pe_align_offset; } +void add_pvl_to_vgs(struct volume_group *vg, struct pv_list *pvl) +{ + dm_list_add(&vg->pvs, &pvl->list); + vg->pv_count++; +} + + /** * add_pv_to_vg - Add a physical volume to a volume group * @vg - volume group to add to @@ -230,9 +237,7 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, } pvl->pv = pv; - dm_list_add(&vg->pvs, &pvl->list); - - vg->pv_count++; + add_pvl_to_vgs(vg, pvl); vg->extent_count += pv->pe_count; vg->free_count += pv->pe_count; diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 782d30017..1496252d5 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -377,5 +377,6 @@ struct id pv_vgid(const struct physical_volume *pv); struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name); int add_pv_to_vg(struct volume_group *vg, const char *pv_name, struct physical_volume *pv); +void add_pvl_to_vgs(struct volume_group *vg, struct pv_list *pvl); #endif