summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/format_pool/import_export.c2
-rw-r--r--lib/metadata/metadata.h4
-rw-r--r--lib/metadata/pv_map.c6
-rw-r--r--tools/lvcreate.c2
-rw-r--r--tools/lvresize.c2
-rw-r--r--tools/pvmove.c2
-rw-r--r--tools/toollib.c64
-rw-r--r--tools/toollib.h4
9 files changed, 45 insertions, 42 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 85c2cf8e..77d5b205 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.00.21 -
=============================
+ Change alloc_areas to pe_ranges and allow suppression of availability checks.
Add dev_size column to pvs.
Add report columns for in-kernel device number.
diff --git a/lib/format_pool/import_export.c b/lib/format_pool/import_export.c
index 61752128..8df67939 100644
--- a/lib/format_pool/import_export.c
+++ b/lib/format_pool/import_export.c
@@ -146,7 +146,7 @@ int import_pool_pvs(const struct format_type *fmt, struct volume_group *vg,
}
pl->pv = pvl->pv;
pvl->mdas = NULL;
- pvl->alloc_areas = NULL;
+ pvl->pe_ranges = NULL;
list_add(pvs, &pvl->list);
}
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 3d57c639..1340f7b0 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -265,7 +265,7 @@ struct name_list {
char *name;
};
-struct alloc_area {
+struct pe_range {
struct list list;
uint32_t start; /* PEs */
uint32_t count; /* PEs */
@@ -275,7 +275,7 @@ struct pv_list {
struct list list;
struct physical_volume *pv;
struct list *mdas; /* Metadata areas */
- struct list *alloc_areas; /* Areas we may allocate from */
+ struct list *pe_ranges; /* Ranges of PEs e.g. for allocation */
};
struct lv_list {
diff --git a/lib/metadata/pv_map.c b/lib/metadata/pv_map.c
index 6f047877..11800690 100644
--- a/lib/metadata/pv_map.c
+++ b/lib/metadata/pv_map.c
@@ -206,13 +206,13 @@ static int _create_areas(struct pool *mem, struct pv_map *pvm, uint32_t start,
static int _create_allocatable_areas(struct pool *mem, struct pv_map *pvm)
{
struct list *alloc_areas, *aah;
- struct alloc_area *aa;
+ struct pe_range *aa;
- alloc_areas = pvm->pvl->alloc_areas;
+ alloc_areas = pvm->pvl->pe_ranges;
if (alloc_areas) {
list_iterate(aah, alloc_areas) {
- aa = list_item(aah, struct alloc_area);
+ aa = list_item(aah, struct pe_range);
if (!_create_areas(mem, pvm, aa->start, aa->count)) {
stack;
return 0;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index f87702a2..e2117b4a 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -418,7 +418,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
*/
if (lp->pv_count) {
if (!(pvh = create_pv_list(cmd->mem, vg,
- lp->pv_count, lp->pvs))) {
+ lp->pv_count, lp->pvs, 1))) {
stack;
return 0;
}
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 7760fc6f..8ffd2225 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -351,7 +351,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (lp->argc)
log_print("Ignoring PVs on command line when reducing");
} else if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc,
- lp->argv) : &vg->pvs)) {
+ lp->argv, 1) : &vg->pvs)) {
stack;
return ECMD_FAILED;
}
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 7af3de8d..f0cb73c2 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -92,7 +92,7 @@ static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc,
if (argc) {
if (!(allocatable_pvs = create_pv_list(cmd->mem, vg, argc,
- argv))) {
+ argv, 1))) {
stack;
return NULL;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 092e1bfe..5ddcea9e 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -694,40 +694,40 @@ char *default_vgname(struct cmd_context *cmd)
return pool_strdup(cmd->mem, vg_path);
}
-static int _add_alloc_area(struct pool *mem, struct list *alloc_areas,
- uint32_t start, uint32_t count)
+static int _add_pe_range(struct pool *mem, struct list *pe_ranges,
+ uint32_t start, uint32_t count)
{
- struct alloc_area *aa;
+ struct pe_range *per;
- log_debug("Adding alloc area: start PE %" PRIu32 " length %" PRIu32,
+ log_debug("Adding PE range: start PE %" PRIu32 " length %" PRIu32,
start, count);
/* Ensure no overlap with existing areas */
- list_iterate_items(aa, alloc_areas) {
- if (((start < aa->start) && (start + count - 1 >= aa->start)) ||
- ((start >= aa->start) &&
- (aa->start + aa->count - 1) >= start)) {
+ list_iterate_items(per, pe_ranges) {
+ if (((start < per->start) && (start + count - 1 >= per->start))
+ || ((start >= per->start) &&
+ (per->start + per->count - 1) >= start)) {
log_error("Overlapping PE ranges detected (%" PRIu32
"-%" PRIu32 ", %" PRIu32 "-%" PRIu32 ")",
- start, start + count - 1, aa->start,
- aa->start + aa->count - 1);
+ start, start + count - 1, per->start,
+ per->start + per->count - 1);
return 0;
}
}
- if (!(aa = pool_alloc(mem, sizeof(*aa)))) {
+ if (!(per = pool_alloc(mem, sizeof(*per)))) {
log_error("Allocation of list failed");
return 0;
}
- aa->start = start;
- aa->count = count;
- list_add(alloc_areas, &aa->list);
+ per->start = start;
+ per->count = count;
+ list_add(pe_ranges, &per->list);
return 1;
}
-static int _parse_pes(struct pool *mem, char *c, struct list *alloc_areas,
+static int _parse_pes(struct pool *mem, char *c, struct list *pe_ranges,
uint32_t size)
{
char *endptr;
@@ -735,7 +735,7 @@ static int _parse_pes(struct pool *mem, char *c, struct list *alloc_areas,
/* Default to whole PV */
if (!c) {
- if (!_add_alloc_area(mem, alloc_areas, UINT32_C(0), size)) {
+ if (!_add_pe_range(mem, pe_ranges, UINT32_C(0), size)) {
stack;
return 0;
}
@@ -785,7 +785,7 @@ static int _parse_pes(struct pool *mem, char *c, struct list *alloc_areas,
return 0;
}
- if (!_add_alloc_area(mem, alloc_areas, start, end - start + 1)) {
+ if (!_add_pe_range(mem, pe_ranges, start, end - start + 1)) {
stack;
return 0;
}
@@ -800,19 +800,20 @@ static int _parse_pes(struct pool *mem, char *c, struct list *alloc_areas,
}
static void _create_pv_entry(struct pool *mem, struct pv_list *pvl,
- char *colon, struct list *r)
+ char *colon, int allocatable_only, struct list *r)
{
const char *pvname;
struct pv_list *new_pvl;
- struct list *alloc_areas;
+ struct list *pe_ranges;
pvname = dev_name(pvl->pv->dev);
- if (!(pvl->pv->status & ALLOCATABLE_PV)) {
+ if (allocatable_only && !(pvl->pv->status & ALLOCATABLE_PV)) {
log_error("Physical volume %s not allocatable", pvname);
return;
}
- if (pvl->pv->pe_count == pvl->pv->pe_alloc_count) {
+ if (allocatable_only &&
+ (pvl->pv->pe_count == pvl->pv->pe_alloc_count)) {
log_err("No free extents on physical volume \"%s\"", pvname);
return;
}
@@ -824,24 +825,24 @@ static void _create_pv_entry(struct pool *mem, struct pv_list *pvl,
memcpy(new_pvl, pvl, sizeof(*new_pvl));
- if (!(alloc_areas = pool_alloc(mem, sizeof(*alloc_areas)))) {
- log_error("Allocation of alloc_areas list failed");
+ if (!(pe_ranges = pool_alloc(mem, sizeof(*pe_ranges)))) {
+ log_error("Allocation of pe_ranges list failed");
return;
}
- list_init(alloc_areas);
+ list_init(pe_ranges);
- /* Specify which physical extents may be used for allocation */
- if (!_parse_pes(mem, colon, alloc_areas, pvl->pv->pe_count)) {
+ /* Determine selected physical extents */
+ if (!_parse_pes(mem, colon, pe_ranges, pvl->pv->pe_count)) {
stack;
return;
}
- new_pvl->alloc_areas = alloc_areas;
+ new_pvl->pe_ranges = pe_ranges;
list_add(r, &new_pvl->list);
}
-struct list *create_pv_list(struct pool *mem,
- struct volume_group *vg, int argc, char **argv)
+struct list *create_pv_list(struct pool *mem, struct volume_group *vg, int argc,
+ char **argv, int allocatable_only)
{
struct list *r;
struct pv_list *pvl;
@@ -870,7 +871,8 @@ struct list *create_pv_list(struct pool *mem,
list_iterate_items(pvl, &vg->pvs) {
if (str_list_match_item(&pvl->pv->tags,
tagname)) {
- _create_pv_entry(mem, pvl, NULL, r);
+ _create_pv_entry(mem, pvl, NULL,
+ allocatable_only, r);
}
}
continue;
@@ -892,7 +894,7 @@ struct list *create_pv_list(struct pool *mem,
"Volume Group \"%s\"", pvname, vg->name);
return NULL;
}
- _create_pv_entry(mem, pvl, colon, r);
+ _create_pv_entry(mem, pvl, colon, allocatable_only, r);
}
if (list_empty(r))
diff --git a/tools/toollib.h b/tools/toollib.h
index 78a01e8e..ff663ed9 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -74,8 +74,8 @@ const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
* Builds a list of pv's from the names in argv. Used in
* lvcreate/extend.
*/
-struct list *create_pv_list(struct pool *mem,
- struct volume_group *vg, int argc, char **argv);
+struct list *create_pv_list(struct pool *mem, struct volume_group *vg, int argc,
+ char **argv, int allocatable_only);
struct list *clone_pv_list(struct pool *mem, struct list *pvs);