summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-02-16 12:49:57 -0600
committerDavid Teigland <teigland@redhat.com>2016-02-18 11:02:18 -0600
commit25222504152f9595017c52bc98a138087240ab12 (patch)
tree2923ead8ede784413b8d8bfc302031375ba29ed0
parent7a7b2821614bd44def0f8ca6cf50a6354f4220c1 (diff)
downloadlvm2-25222504152f9595017c52bc98a138087240ab12.tar.gz
metadata: refactor part of add_pv_to_vg
This shifts the use of the 'pv_to_write' struct and the 'pvcreate_params' struct to the one caller of add_pv_to_vg, which is made static.
-rw-r--r--lib/metadata/metadata.c34
-rw-r--r--lib/metadata/metadata.h4
2 files changed, 16 insertions, 22 deletions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index fd2505023..1d8d779ca 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -169,18 +169,15 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
* @vg - volume group to add to
* @pv_name - name of the pv (to be removed)
* @pv - physical volume to add to volume group
- * @pp - physical volume creation params (OPTIONAL)
*
* Returns:
* 0 - failure
* 1 - success
* 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,
- int new_pv)
+static int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
+ struct physical_volume *pv, int new_pv)
{
- struct pv_to_write *pvw;
struct pv_list *pvl;
struct format_instance *fid = vg->fid;
struct dm_pool *mem = vg->vgmem;
@@ -289,18 +286,6 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
break;
}
- if ((pv->fmt->features & FMT_PV_FLAGS) ||
- (pv->status & UNLABELLED_PV)) {
- if (!(pvw = dm_pool_zalloc(mem, sizeof(*pvw)))) {
- log_error("pv_to_write allocation for '%s' failed", pv_name);
- return 0;
- }
- pvw->pv = pv;
- pvw->pp = new_pv ? pp : NULL;
- pvw->new_pv = new_pv;
- dm_list_add(&vg->pvs_to_write, &pvw->list);
- }
-
return 1;
}
@@ -723,6 +708,7 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
unsigned int *max_phys_block_size)
{
struct physical_volume *pv;
+ struct pv_to_write *pvw;
int new_pv = 0;
pv = find_pv_by_name(vg->cmd, pv_name, 1, 1);
@@ -741,9 +727,21 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
max_phys_block_size)))
goto_bad;
- if (!add_pv_to_vg(vg, pv_name, pv, pp, new_pv))
+ if (!add_pv_to_vg(vg, pv_name, pv, new_pv))
goto_bad;
+ if ((pv->fmt->features & FMT_PV_FLAGS) ||
+ (pv->status & UNLABELLED_PV)) {
+ if (!(pvw = dm_pool_zalloc(vg->vgmem, sizeof(*pvw)))) {
+ log_error("pv_to_write allocation for '%s' failed", pv_name);
+ return 0;
+ }
+ pvw->pv = pv;
+ pvw->pp = new_pv ? pp : NULL;
+ pvw->new_pv = new_pv;
+ dm_list_add(&vg->pvs_to_write, &pvw->list);
+ }
+
return 1;
bad:
free_pv_fid(pv);
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index f2b62e477..192f88e6c 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -504,10 +504,6 @@ struct id pv_id(const struct physical_volume *pv);
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,
- 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);