From: Dave Wysochanski Date: Mon, 5 Oct 2009 20:02:30 +0000 (+0000) Subject: Add pvcreate_params to vg_extend_single_pv. X-Git-Tag: old-v2_02_54~43 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=839af3e90eccf5398d0936906d690bcb7f26d48e;p=lvm2.git Add pvcreate_params to vg_extend_single_pv. Should be no functional change. If this parameter is set to NULL, just fail the extend if the device is not already a PV. If non-NULL, try pvcreate_single before failing. Note that pvcreate_single() handles the log_error in case of failure so we just return 0 if pvcreate_single() fails. --- diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 07af5b1f3..b6f84d7c8 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -559,16 +559,23 @@ int vg_remove(struct volume_group *vg) * Parameters: * - vg: handle of volume group to extend by 'pv_name' * - pv_name: device path of PV to add to VG + * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate * */ -static int vg_extend_single_pv(struct volume_group *vg, char *pv_name) +static int vg_extend_single_pv(struct volume_group *vg, char *pv_name, + struct pvcreate_params *pp) { struct physical_volume *pv; - if (!(pv = pv_by_path(vg->fid->fmt->cmd, pv_name))) { + pv = pv_by_path(vg->fid->fmt->cmd, pv_name); + if (!pv && !pp) { log_error("%s not identified as an existing " "physical volume", pv_name); return 0; + } else if (!pv && pp) { + pv = pvcreate_single(vg->cmd, pv_name, pp); + if (!pv) + return 0; } if (!add_pv_to_vg(vg, pv_name, pv)) return 0; @@ -584,7 +591,7 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names) /* attach each pv */ for (i = 0; i < pv_count; i++) { - if (!vg_extend_single_pv(vg, pv_names[i])) + if (!vg_extend_single_pv(vg, pv_names[i], NULL)) goto bad; }