mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

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

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