diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-03-12 14:37:50 +0100 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2016-02-15 12:44:46 +0100 |
commit | 2950adc2ab67fd14173807164f9829f5f53cd33c (patch) | |
tree | cf56ad3d5fa6355e6deb07c93b0dc295b793ebde | |
parent | 4cbaaa5c98c78784e9eab5489c12d2e72e952f32 (diff) | |
download | lvm2-2950adc2ab67fd14173807164f9829f5f53cd33c.tar.gz |
metadata: add_pv_to_vg: add 'new_pv' arg to state if the PV is about to be created
-rw-r--r-- | lib/metadata/metadata.c | 11 | ||||
-rw-r--r-- | lib/metadata/metadata.h | 3 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 0ca17f666..981bfbc96 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -177,7 +177,8 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl) * FIXME: remove pv_name - obtain safely from pv */ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, - struct physical_volume *pv, struct pvcreate_params *pp) + struct physical_volume *pv, struct pvcreate_params *pp, + int new_pv) { struct pv_to_write *pvw; struct pv_list *pvl; @@ -284,7 +285,7 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, return 0; } pvw->pv = pv; - pvw->pp = pp; + pvw->pp = new_pv ? pp : NULL; dm_list_add(&vg->pvs_to_write, &pvw->list); } @@ -710,6 +711,7 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name, unsigned int *max_phys_block_size) { struct physical_volume *pv; + int new_pv = 0; pv = find_pv_by_name(vg->cmd, pv_name, 1, 1); @@ -720,13 +722,14 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name, } else if (!pv && pp) { if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0))) return_0; + new_pv = 1; } if (!(check_dev_block_size_for_vg(pv->dev, (const struct volume_group *) vg, max_phys_block_size))) goto_bad; - if (!add_pv_to_vg(vg, pv_name, pv, pp)) + if (!add_pv_to_vg(vg, pv_name, pv, pp, new_pv)) goto_bad; return 1; @@ -1610,7 +1613,7 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp) static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw) { - int zero = pvw->pp->zero; + int zero = pvw->pp ? pvw->pp->zero : 1; struct physical_volume *pv = pvw->pv; struct device *dev = pv->dev; const char *pv_name = dev_name(dev); diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 3891b2647..3f5f5aeae 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -496,7 +496,8 @@ const struct format_type *pv_format_type(const struct physical_volume *pv); struct id pv_vgid(const struct physical_volume *pv); int add_pv_to_vg(struct volume_group *vg, const char *pv_name, - struct physical_volume *pv, struct pvcreate_params *pp); + struct physical_volume *pv, struct pvcreate_params *pp, + int new_pv); uint64_t find_min_mda_size(struct dm_list *mdas); char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl); |