Blame SOURCES/lvm2-2_03_10-move-pv_list-code-into-lib.patch

18db87
From 945de675c47d891d1f181f15971d26ff959ac631 Mon Sep 17 00:00:00 2001
18db87
From: David Teigland <teigland@redhat.com>
18db87
Date: Tue, 14 Jan 2020 14:12:20 -0600
18db87
Subject: [PATCH 1/3] move pv_list code into lib
18db87
18db87
(cherry picked from commit b6b4ad8e28eff7476cb04c4cb93312b06605b82f)
18db87
---
18db87
 lib/Makefile.in                  |   1 +
18db87
 lib/metadata/metadata-exported.h |   4 +
18db87
 lib/metadata/pv_list.c           | 291 +++++++++++++++++++++++++++++++++++++++
18db87
 tools/toollib.c                  | 270 ------------------------------------
18db87
 tools/toollib.h                  |   9 --
18db87
 5 files changed, 296 insertions(+), 279 deletions(-)
18db87
 create mode 100644 lib/metadata/pv_list.c
18db87
18db87
diff --git a/lib/Makefile.in b/lib/Makefile.in
18db87
index c037b41..2a064f3 100644
18db87
--- a/lib/Makefile.in
18db87
+++ b/lib/Makefile.in
18db87
@@ -74,6 +74,7 @@ SOURCES =\
18db87
 	metadata/mirror.c \
18db87
 	metadata/pool_manip.c \
18db87
 	metadata/pv.c \
18db87
+	metadata/pv_list.c \
18db87
 	metadata/pv_manip.c \
18db87
 	metadata/pv_map.c \
18db87
 	metadata/raid_manip.c \
18db87
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
18db87
index c61c85c..35c1231 100644
18db87
--- a/lib/metadata/metadata-exported.h
18db87
+++ b/lib/metadata/metadata-exported.h
18db87
@@ -1385,4 +1385,8 @@ int vg_is_foreign(struct volume_group *vg);
18db87
 
18db87
 void vg_write_commit_bad_mdas(struct cmd_context *cmd, struct volume_group *vg);
18db87
 
18db87
+struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
18db87
+		                                            char **argv, int allocatable_only);
18db87
+struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl);
18db87
+
18db87
 #endif
18db87
diff --git a/lib/metadata/pv_list.c b/lib/metadata/pv_list.c
18db87
new file mode 100644
18db87
index 0000000..143b573
18db87
--- /dev/null
18db87
+++ b/lib/metadata/pv_list.c
18db87
@@ -0,0 +1,291 @@
18db87
+/*
18db87
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
18db87
+ * Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
18db87
+ *
18db87
+ * This file is part of LVM2.
18db87
+ *
18db87
+ * This copyrighted material is made available to anyone wishing to use,
18db87
+ * modify, copy, or redistribute it subject to the terms and conditions
18db87
+ * of the GNU Lesser General Public License v.2.1.
18db87
+ *
18db87
+ * You should have received a copy of the GNU Lesser General Public License
18db87
+ * along with this program; if not, write to the Free Software Foundation,
18db87
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18db87
+ */
18db87
+
18db87
+#include "lib/misc/lib.h"
18db87
+#include "lib/misc/lvm-string.h"
18db87
+#include "lib/datastruct/str_list.h"
18db87
+#include "lib/device/device.h"
18db87
+#include "lib/metadata/metadata.h"
18db87
+
18db87
+/*
18db87
+ * Process physical extent range specifiers
18db87
+ */
18db87
+static int _add_pe_range(struct dm_pool *mem, const char *pvname,
18db87
+			 struct dm_list *pe_ranges, uint32_t start, uint32_t count)
18db87
+{
18db87
+	struct pe_range *per;
18db87
+
18db87
+	log_debug("Adding PE range: start PE " FMTu32 " length " FMTu32 " on %s.",
18db87
+		  start, count, pvname);
18db87
+
18db87
+	/* Ensure no overlap with existing areas */
18db87
+	dm_list_iterate_items(per, pe_ranges) {
18db87
+		if (((start < per->start) && (start + count - 1 >= per->start)) ||
18db87
+		    ((start >= per->start) &&
18db87
+			(per->start + per->count - 1) >= start)) {
18db87
+			log_error("Overlapping PE ranges specified (" FMTu32
18db87
+				  "-" FMTu32 ", " FMTu32 "-" FMTu32 ") on %s.",
18db87
+				  start, start + count - 1, per->start,
18db87
+				  per->start + per->count - 1, pvname);
18db87
+			return 0;
18db87
+		}
18db87
+	}
18db87
+
18db87
+	if (!(per = dm_pool_alloc(mem, sizeof(*per)))) {
18db87
+		log_error("Allocation of list failed.");
18db87
+		return 0;
18db87
+	}
18db87
+
18db87
+	per->start = start;
18db87
+	per->count = count;
18db87
+	dm_list_add(pe_ranges, &per->list);
18db87
+
18db87
+	return 1;
18db87
+}
18db87
+
18db87
+static int _xstrtouint32(const char *s, char **p, int base, uint32_t *result)
18db87
+{
18db87
+	unsigned long ul;
18db87
+
18db87
+	errno = 0;
18db87
+	ul = strtoul(s, p, base);
18db87
+
18db87
+	if (errno || *p == s || ul > UINT32_MAX)
18db87
+		return 0;
18db87
+
18db87
+	*result = ul;
18db87
+
18db87
+	return 1;
18db87
+}
18db87
+
18db87
+static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
18db87
+		      const char *pvname, uint32_t size)
18db87
+{
18db87
+	char *endptr;
18db87
+	uint32_t start, end, len;
18db87
+
18db87
+	/* Default to whole PV */
18db87
+	if (!c) {
18db87
+		if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size))
18db87
+			return_0;
18db87
+		return 1;
18db87
+	}
18db87
+
18db87
+	while (*c) {
18db87
+		if (*c != ':')
18db87
+			goto error;
18db87
+
18db87
+		c++;
18db87
+
18db87
+		/* Disallow :: and :\0 */
18db87
+		if (*c == ':' || !*c)
18db87
+			goto error;
18db87
+
18db87
+		/* Default to whole range */
18db87
+		start = UINT32_C(0);
18db87
+		end = size - 1;
18db87
+
18db87
+		/* Start extent given? */
18db87
+		if (isdigit(*c)) {
18db87
+			if (!_xstrtouint32(c, &endptr, 10, &start))
18db87
+				goto error;
18db87
+			c = endptr;
18db87
+			/* Just one number given? */
18db87
+			if (!*c || *c == ':')
18db87
+				end = start;
18db87
+		}
18db87
+		/* Range? */
18db87
+		if (*c == '-') {
18db87
+			c++;
18db87
+			if (isdigit(*c)) {
18db87
+				if (!_xstrtouint32(c, &endptr, 10, &end))
18db87
+					goto error;
18db87
+				c = endptr;
18db87
+			}
18db87
+		} else if (*c == '+') {	/* Length? */
18db87
+			c++;
18db87
+			if (isdigit(*c)) {
18db87
+				if (!_xstrtouint32(c, &endptr, 10, &len))
18db87
+					goto error;
18db87
+				c = endptr;
18db87
+				end = start + (len ? (len - 1) : 0);
18db87
+			}
18db87
+		}
18db87
+
18db87
+		if (*c && *c != ':')
18db87
+			goto error;
18db87
+
18db87
+		if ((start > end) || (end > size - 1)) {
18db87
+			log_error("PE range error: start extent %" PRIu32 " to "
18db87
+				  "end extent %" PRIu32 ".", start, end);
18db87
+			return 0;
18db87
+		}
18db87
+
18db87
+		if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1))
18db87
+			return_0;
18db87
+
18db87
+	}
18db87
+
18db87
+	return 1;
18db87
+
18db87
+      error:
18db87
+	log_error("Physical extent parsing error at %s.", c);
18db87
+	return 0;
18db87
+}
18db87
+
18db87
+static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
18db87
+			     char *colon, int allocatable_only, struct dm_list *r)
18db87
+{
18db87
+	const char *pvname;
18db87
+	struct pv_list *new_pvl = NULL, *pvl2;
18db87
+	struct dm_list *pe_ranges;
18db87
+
18db87
+	pvname = pv_dev_name(pvl->pv);
18db87
+	if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
18db87
+		log_warn("WARNING: Physical volume %s not allocatable.", pvname);
18db87
+		return 1;
18db87
+	}
18db87
+
18db87
+	if (allocatable_only && is_missing_pv(pvl->pv)) {
18db87
+		log_warn("WARNING: Physical volume %s is missing.", pvname);
18db87
+		return 1;
18db87
+	}
18db87
+
18db87
+	if (allocatable_only &&
18db87
+	    (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
18db87
+		log_warn("WARNING: No free extents on physical volume \"%s\".", pvname);
18db87
+		return 1;
18db87
+	}
18db87
+
18db87
+	dm_list_iterate_items(pvl2, r)
18db87
+		if (pvl->pv->dev == pvl2->pv->dev) {
18db87
+			new_pvl = pvl2;
18db87
+			break;
18db87
+		}
18db87
+
18db87
+	if (!new_pvl) {
18db87
+		if (!(new_pvl = dm_pool_alloc(mem, sizeof(*new_pvl)))) {
18db87
+			log_error("Unable to allocate physical volume list.");
18db87
+			return 0;
18db87
+		}
18db87
+
18db87
+		memcpy(new_pvl, pvl, sizeof(*new_pvl));
18db87
+
18db87
+		if (!(pe_ranges = dm_pool_alloc(mem, sizeof(*pe_ranges)))) {
18db87
+			log_error("Allocation of pe_ranges list failed.");
18db87
+			return 0;
18db87
+		}
18db87
+		dm_list_init(pe_ranges);
18db87
+		new_pvl->pe_ranges = pe_ranges;
18db87
+		dm_list_add(r, &new_pvl->list);
18db87
+	}
18db87
+
18db87
+	/* Determine selected physical extents */
18db87
+	if (!_parse_pes(mem, colon, new_pvl->pe_ranges, pv_dev_name(pvl->pv),
18db87
+			pvl->pv->pe_count))
18db87
+		return_0;
18db87
+
18db87
+	return 1;
18db87
+}
18db87
+
18db87
+struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
18db87
+			    char **argv, int allocatable_only)
18db87
+{
18db87
+	struct dm_list *r;
18db87
+	struct pv_list *pvl;
18db87
+	struct dm_list tagsl, arg_pvnames;
18db87
+	char *pvname = NULL;
18db87
+	char *colon, *at_sign, *tagname;
18db87
+	int i;
18db87
+
18db87
+	/* Build up list of PVs */
18db87
+	if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
18db87
+		log_error("Allocation of list failed.");
18db87
+		return NULL;
18db87
+	}
18db87
+	dm_list_init(r);
18db87
+
18db87
+	dm_list_init(&tagsl);
18db87
+	dm_list_init(&arg_pvnames);
18db87
+
18db87
+	for (i = 0; i < argc; i++) {
18db87
+		dm_unescape_colons_and_at_signs(argv[i], &colon, &at_sign);
18db87
+
18db87
+		if (at_sign && (at_sign == argv[i])) {
18db87
+			tagname = at_sign + 1;
18db87
+			if (!validate_tag(tagname)) {
18db87
+				log_error("Skipping invalid tag %s.", tagname);
18db87
+				continue;
18db87
+			}
18db87
+			dm_list_iterate_items(pvl, &vg->pvs) {
18db87
+				if (str_list_match_item(&pvl->pv->tags,
18db87
+							tagname)) {
18db87
+					if (!_create_pv_entry(mem, pvl, NULL,
18db87
+							      allocatable_only,
18db87
+							      r))
18db87
+						return_NULL;
18db87
+				}
18db87
+			}
18db87
+			continue;
18db87
+		}
18db87
+
18db87
+		pvname = argv[i];
18db87
+
18db87
+		if (colon && !(pvname = dm_pool_strndup(mem, pvname,
18db87
+					(unsigned) (colon - pvname)))) {
18db87
+			log_error("Failed to clone PV name.");
18db87
+			return NULL;
18db87
+		}
18db87
+
18db87
+		if (!(pvl = find_pv_in_vg(vg, pvname))) {
18db87
+			log_error("Physical Volume \"%s\" not found in "
18db87
+				  "Volume Group \"%s\".", pvname, vg->name);
18db87
+			return NULL;
18db87
+		}
18db87
+		if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r))
18db87
+			return_NULL;
18db87
+	}
18db87
+
18db87
+	if (dm_list_empty(r))
18db87
+		log_error("No specified PVs have space available.");
18db87
+
18db87
+	return dm_list_empty(r) ? NULL : r;
18db87
+}
18db87
+
18db87
+struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl)
18db87
+{
18db87
+	struct dm_list *r;
18db87
+	struct pv_list *pvl, *new_pvl;
18db87
+
18db87
+	/* Build up list of PVs */
18db87
+	if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
18db87
+		log_error("Allocation of list failed.");
18db87
+		return NULL;
18db87
+	}
18db87
+	dm_list_init(r);
18db87
+
18db87
+	dm_list_iterate_items(pvl, pvsl) {
18db87
+		if (!(new_pvl = dm_pool_zalloc(mem, sizeof(*new_pvl)))) {
18db87
+			log_error("Unable to allocate physical volume list.");
18db87
+			return NULL;
18db87
+		}
18db87
+
18db87
+		memcpy(new_pvl, pvl, sizeof(*new_pvl));
18db87
+		dm_list_add(r, &new_pvl->list);
18db87
+	}
18db87
+
18db87
+	return r;
18db87
+}
18db87
+
18db87
diff --git a/tools/toollib.c b/tools/toollib.c
18db87
index a5304bf..6386a69 100644
18db87
--- a/tools/toollib.c
18db87
+++ b/tools/toollib.c
18db87
@@ -457,276 +457,6 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
18db87
 	return vg_name;
18db87
 }
18db87
 
18db87
-/*
18db87
- * Process physical extent range specifiers
18db87
- */
18db87
-static int _add_pe_range(struct dm_pool *mem, const char *pvname,
18db87
-			 struct dm_list *pe_ranges, uint32_t start, uint32_t count)
18db87
-{
18db87
-	struct pe_range *per;
18db87
-
18db87
-	log_debug("Adding PE range: start PE " FMTu32 " length " FMTu32 " on %s.",
18db87
-		  start, count, pvname);
18db87
-
18db87
-	/* Ensure no overlap with existing areas */
18db87
-	dm_list_iterate_items(per, pe_ranges) {
18db87
-		if (((start < per->start) && (start + count - 1 >= per->start)) ||
18db87
-		    ((start >= per->start) &&
18db87
-			(per->start + per->count - 1) >= start)) {
18db87
-			log_error("Overlapping PE ranges specified (" FMTu32
18db87
-				  "-" FMTu32 ", " FMTu32 "-" FMTu32 ") on %s.",
18db87
-				  start, start + count - 1, per->start,
18db87
-				  per->start + per->count - 1, pvname);
18db87
-			return 0;
18db87
-		}
18db87
-	}
18db87
-
18db87
-	if (!(per = dm_pool_alloc(mem, sizeof(*per)))) {
18db87
-		log_error("Allocation of list failed.");
18db87
-		return 0;
18db87
-	}
18db87
-
18db87
-	per->start = start;
18db87
-	per->count = count;
18db87
-	dm_list_add(pe_ranges, &per->list);
18db87
-
18db87
-	return 1;
18db87
-}
18db87
-
18db87
-static int _xstrtouint32(const char *s, char **p, int base, uint32_t *result)
18db87
-{
18db87
-	unsigned long ul;
18db87
-
18db87
-	errno = 0;
18db87
-	ul = strtoul(s, p, base);
18db87
-
18db87
-	if (errno || *p == s || ul > UINT32_MAX)
18db87
-		return 0;
18db87
-
18db87
-	*result = ul;
18db87
-
18db87
-	return 1;
18db87
-}
18db87
-
18db87
-static int _parse_pes(struct dm_pool *mem, char *c, struct dm_list *pe_ranges,
18db87
-		      const char *pvname, uint32_t size)
18db87
-{
18db87
-	char *endptr;
18db87
-	uint32_t start, end, len;
18db87
-
18db87
-	/* Default to whole PV */
18db87
-	if (!c) {
18db87
-		if (!_add_pe_range(mem, pvname, pe_ranges, UINT32_C(0), size))
18db87
-			return_0;
18db87
-		return 1;
18db87
-	}
18db87
-
18db87
-	while (*c) {
18db87
-		if (*c != ':')
18db87
-			goto error;
18db87
-
18db87
-		c++;
18db87
-
18db87
-		/* Disallow :: and :\0 */
18db87
-		if (*c == ':' || !*c)
18db87
-			goto error;
18db87
-
18db87
-		/* Default to whole range */
18db87
-		start = UINT32_C(0);
18db87
-		end = size - 1;
18db87
-
18db87
-		/* Start extent given? */
18db87
-		if (isdigit(*c)) {
18db87
-			if (!_xstrtouint32(c, &endptr, 10, &start))
18db87
-				goto error;
18db87
-			c = endptr;
18db87
-			/* Just one number given? */
18db87
-			if (!*c || *c == ':')
18db87
-				end = start;
18db87
-		}
18db87
-		/* Range? */
18db87
-		if (*c == '-') {
18db87
-			c++;
18db87
-			if (isdigit(*c)) {
18db87
-				if (!_xstrtouint32(c, &endptr, 10, &end))
18db87
-					goto error;
18db87
-				c = endptr;
18db87
-			}
18db87
-		} else if (*c == '+') {	/* Length? */
18db87
-			c++;
18db87
-			if (isdigit(*c)) {
18db87
-				if (!_xstrtouint32(c, &endptr, 10, &len))
18db87
-					goto error;
18db87
-				c = endptr;
18db87
-				end = start + (len ? (len - 1) : 0);
18db87
-			}
18db87
-		}
18db87
-
18db87
-		if (*c && *c != ':')
18db87
-			goto error;
18db87
-
18db87
-		if ((start > end) || (end > size - 1)) {
18db87
-			log_error("PE range error: start extent %" PRIu32 " to "
18db87
-				  "end extent %" PRIu32 ".", start, end);
18db87
-			return 0;
18db87
-		}
18db87
-
18db87
-		if (!_add_pe_range(mem, pvname, pe_ranges, start, end - start + 1))
18db87
-			return_0;
18db87
-
18db87
-	}
18db87
-
18db87
-	return 1;
18db87
-
18db87
-      error:
18db87
-	log_error("Physical extent parsing error at %s.", c);
18db87
-	return 0;
18db87
-}
18db87
-
18db87
-static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl,
18db87
-			     char *colon, int allocatable_only, struct dm_list *r)
18db87
-{
18db87
-	const char *pvname;
18db87
-	struct pv_list *new_pvl = NULL, *pvl2;
18db87
-	struct dm_list *pe_ranges;
18db87
-
18db87
-	pvname = pv_dev_name(pvl->pv);
18db87
-	if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
18db87
-		log_warn("WARNING: Physical volume %s not allocatable.", pvname);
18db87
-		return 1;
18db87
-	}
18db87
-
18db87
-	if (allocatable_only && is_missing_pv(pvl->pv)) {
18db87
-		log_warn("WARNING: Physical volume %s is missing.", pvname);
18db87
-		return 1;
18db87
-	}
18db87
-
18db87
-	if (allocatable_only &&
18db87
-	    (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
18db87
-		log_warn("WARNING: No free extents on physical volume \"%s\".", pvname);
18db87
-		return 1;
18db87
-	}
18db87
-
18db87
-	dm_list_iterate_items(pvl2, r)
18db87
-		if (pvl->pv->dev == pvl2->pv->dev) {
18db87
-			new_pvl = pvl2;
18db87
-			break;
18db87
-		}
18db87
-
18db87
-	if (!new_pvl) {
18db87
-		if (!(new_pvl = dm_pool_alloc(mem, sizeof(*new_pvl)))) {
18db87
-			log_error("Unable to allocate physical volume list.");
18db87
-			return 0;
18db87
-		}
18db87
-
18db87
-		memcpy(new_pvl, pvl, sizeof(*new_pvl));
18db87
-
18db87
-		if (!(pe_ranges = dm_pool_alloc(mem, sizeof(*pe_ranges)))) {
18db87
-			log_error("Allocation of pe_ranges list failed.");
18db87
-			return 0;
18db87
-		}
18db87
-		dm_list_init(pe_ranges);
18db87
-		new_pvl->pe_ranges = pe_ranges;
18db87
-		dm_list_add(r, &new_pvl->list);
18db87
-	}
18db87
-
18db87
-	/* Determine selected physical extents */
18db87
-	if (!_parse_pes(mem, colon, new_pvl->pe_ranges, pv_dev_name(pvl->pv),
18db87
-			pvl->pv->pe_count))
18db87
-		return_0;
18db87
-
18db87
-	return 1;
18db87
-}
18db87
-
18db87
-struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
18db87
-			    char **argv, int allocatable_only)
18db87
-{
18db87
-	struct dm_list *r;
18db87
-	struct pv_list *pvl;
18db87
-	struct dm_list tagsl, arg_pvnames;
18db87
-	char *pvname = NULL;
18db87
-	char *colon, *at_sign, *tagname;
18db87
-	int i;
18db87
-
18db87
-	/* Build up list of PVs */
18db87
-	if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
18db87
-		log_error("Allocation of list failed.");
18db87
-		return NULL;
18db87
-	}
18db87
-	dm_list_init(r);
18db87
-
18db87
-	dm_list_init(&tagsl);
18db87
-	dm_list_init(&arg_pvnames);
18db87
-
18db87
-	for (i = 0; i < argc; i++) {
18db87
-		dm_unescape_colons_and_at_signs(argv[i], &colon, &at_sign);
18db87
-
18db87
-		if (at_sign && (at_sign == argv[i])) {
18db87
-			tagname = at_sign + 1;
18db87
-			if (!validate_tag(tagname)) {
18db87
-				log_error("Skipping invalid tag %s.", tagname);
18db87
-				continue;
18db87
-			}
18db87
-			dm_list_iterate_items(pvl, &vg->pvs) {
18db87
-				if (str_list_match_item(&pvl->pv->tags,
18db87
-							tagname)) {
18db87
-					if (!_create_pv_entry(mem, pvl, NULL,
18db87
-							      allocatable_only,
18db87
-							      r))
18db87
-						return_NULL;
18db87
-				}
18db87
-			}
18db87
-			continue;
18db87
-		}
18db87
-
18db87
-		pvname = argv[i];
18db87
-
18db87
-		if (colon && !(pvname = dm_pool_strndup(mem, pvname,
18db87
-					(unsigned) (colon - pvname)))) {
18db87
-			log_error("Failed to clone PV name.");
18db87
-			return NULL;
18db87
-		}
18db87
-
18db87
-		if (!(pvl = find_pv_in_vg(vg, pvname))) {
18db87
-			log_error("Physical Volume \"%s\" not found in "
18db87
-				  "Volume Group \"%s\".", pvname, vg->name);
18db87
-			return NULL;
18db87
-		}
18db87
-		if (!_create_pv_entry(mem, pvl, colon, allocatable_only, r))
18db87
-			return_NULL;
18db87
-	}
18db87
-
18db87
-	if (dm_list_empty(r))
18db87
-		log_error("No specified PVs have space available.");
18db87
-
18db87
-	return dm_list_empty(r) ? NULL : r;
18db87
-}
18db87
-
18db87
-struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl)
18db87
-{
18db87
-	struct dm_list *r;
18db87
-	struct pv_list *pvl, *new_pvl;
18db87
-
18db87
-	/* Build up list of PVs */
18db87
-	if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
18db87
-		log_error("Allocation of list failed.");
18db87
-		return NULL;
18db87
-	}
18db87
-	dm_list_init(r);
18db87
-
18db87
-	dm_list_iterate_items(pvl, pvsl) {
18db87
-		if (!(new_pvl = dm_pool_zalloc(mem, sizeof(*new_pvl)))) {
18db87
-			log_error("Unable to allocate physical volume list.");
18db87
-			return NULL;
18db87
-		}
18db87
-
18db87
-		memcpy(new_pvl, pvl, sizeof(*new_pvl));
18db87
-		dm_list_add(r, &new_pvl->list);
18db87
-	}
18db87
-
18db87
-	return r;
18db87
-}
18db87
-
18db87
 const char _pe_size_may_not_be_negative_msg[] = "Physical extent size may not be negative.";
18db87
 
18db87
 int vgcreate_params_set_defaults(struct cmd_context *cmd,
18db87
diff --git a/tools/toollib.h b/tools/toollib.h
18db87
index 9102f55..53a5e5b 100644
18db87
--- a/tools/toollib.h
18db87
+++ b/tools/toollib.h
18db87
@@ -182,15 +182,6 @@ void opt_array_to_str(struct cmd_context *cmd, int *opts, int count,
18db87
 int pvcreate_params_from_args(struct cmd_context *cmd, struct pvcreate_params *pp);
18db87
 int pvcreate_each_device(struct cmd_context *cmd, struct processing_handle *handle, struct pvcreate_params *pp);
18db87
 
18db87
-/*
18db87
- * Builds a list of pv's from the names in argv.  Used in
18db87
- * lvcreate/extend.
18db87
- */
18db87
-struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int argc,
18db87
-			    char **argv, int allocatable_only);
18db87
-
18db87
-struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
18db87
-
18db87
 int vgcreate_params_set_defaults(struct cmd_context *cmd,
18db87
 				 struct vgcreate_params *vp_def,
18db87
 				 struct volume_group *vg);
18db87
-- 
18db87
1.8.3.1
18db87