diff options
Diffstat (limited to 'lib/metadata/metadata.c')
-rw-r--r-- | lib/metadata/metadata.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index a1d2e2b49..efa88884d 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -179,7 +179,6 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl) int add_pv_to_vg(struct volume_group *vg, const char *pv_name, struct physical_volume *pv, struct pvcreate_params *pp) { - struct pv_to_create *pvc; struct pv_list *pvl; struct format_instance *fid = vg->fid; struct dm_pool *mem = vg->vgmem; @@ -274,16 +273,6 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, break; } - if (pv->status & UNLABELLED_PV) { - if (!(pvc = dm_pool_zalloc(mem, sizeof(*pvc)))) { - log_error("pv_to_create allocation for '%s' failed", pv_name); - return 0; - } - pvc->pv = pv; - pvc->pp = pp; - dm_list_add(&vg->pvs_to_create, &pvc->list); - } - return 1; } @@ -743,6 +732,43 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names return 1; } +int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_each_params *pp) +{ + struct pv_list *pvl; + unsigned int max_phys_block_size = 0; + + log_debug_metadata("Adding PVs to VG %s", vg->name); + + if (_vg_bad_status_bits(vg, RESIZEABLE_VG)) + return_0; + + dm_list_iterate_items(pvl, &pp->pvs) { + log_debug_metadata("Adding PV %s to VG %s", pv_dev_name(pvl->pv), vg->name); + + if (!(check_dev_block_size_for_vg(pvl->pv->dev, + (const struct volume_group *) vg, + &max_phys_block_size))) { + log_error("PV %s has wrong block size", pv_dev_name(pvl->pv)); + return_0; + } + + if (!add_pv_to_vg(vg, pv_dev_name(pvl->pv), pvl->pv, NULL)) { + log_error("PV %s cannot be added to the VG.", pv_dev_name(pvl->pv)); + return_0; + } + + log_verbose("Writing PV data to disk for %s VG %s", + pv_dev_name(pvl->pv), vg->name); + + if (!(pv_write(vg->cmd, pvl->pv, 1))) { + log_error("Failed to write physical volume \"%s\"", pv_dev_name(pvl->pv)); + return_0; + } + } + + return 1; +} + int vg_reduce(struct volume_group *vg, const char *pv_name) { struct physical_volume *pv; @@ -1572,7 +1598,6 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp) pp->rp.extent_size = 0; } - static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc) { int zero = pvc->pp->zero; @@ -3012,7 +3037,6 @@ out: int vg_write(struct volume_group *vg) { struct dm_list *mdah; - struct pv_to_create *pv_to_create, *pv_to_create_safe; struct metadata_area *mda; struct lv_list *lvl; int revert = 0, wrote = 0; @@ -3068,12 +3092,6 @@ int vg_write(struct volume_group *vg) memlock_unlock(vg->cmd); vg->seqno++; - dm_list_iterate_items_safe(pv_to_create, pv_to_create_safe, &vg->pvs_to_create) { - if (!_pvcreate_write(vg->cmd, pv_to_create)) - return 0; - dm_list_del(&pv_to_create->list); - } - /* Write to each copy of the metadata area */ dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) { if (!mda->ops->vg_write) { |