summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2004-05-18 22:12:53 +0000
committerAlasdair Kergon <agk@redhat.com>2004-05-18 22:12:53 +0000
commita0a23eff4bd3f0307abcb00521f98dd4fc68f7aa (patch)
tree8c67a5c599ba6fdb54955e0c8f9c4c75dc76cb61 /tools
parentb61702ce8c2de83f9131b6732d356cebee5b059a (diff)
downloadlvm2-a0a23eff4bd3f0307abcb00521f98dd4fc68f7aa.tar.gz
lvm2-a0a23eff4bd3f0307abcb00521f98dd4fc68f7aa.tar.xz
lvm2-a0a23eff4bd3f0307abcb00521f98dd4fc68f7aa.zip
Rename allocation policies; add --alloc to cmdline; LV inherits from VG.
Diffstat (limited to 'tools')
-rw-r--r--tools/args.h1
-rw-r--r--tools/commands.h33
-rw-r--r--tools/lvchange.c62
-rw-r--r--tools/lvcreate.c25
-rw-r--r--tools/lvmcmdline.c15
-rw-r--r--tools/lvresize.c5
-rw-r--r--tools/tools.h1
-rw-r--r--tools/vgchange.c52
-rw-r--r--tools/vgcreate.c10
-rw-r--r--tools/vgsplit.c3
10 files changed, 141 insertions, 66 deletions
diff --git a/tools/args.h b/tools/args.h
index ee0439bc..7cc63dbd 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -42,6 +42,7 @@ arg(refresh_ARG, '\0', "refresh", NULL)
arg(mknodes_ARG, '\0', "mknodes", NULL)
arg(minor_ARG, '\0', "minor", minor_arg)
arg(type_ARG, '\0', "type", segtype_arg)
+arg(alloc_ARG, '\0', "alloc", alloc_arg)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
diff --git a/tools/commands.h b/tools/commands.h
index 2afccc67..82362646 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -52,6 +52,7 @@ xx(lvchange,
"\t[-A|--autobackup y|n]\n"
"\t[-a|--available y|n]\n"
"\t[--addtag Tag]\n"
+ "\t[--alloc AllocationType]\n"
"\t[-C|--contiguous y|n]\n"
"\t[-d|--debug]\n"
"\t[--deltag Tag]\n"
@@ -68,7 +69,7 @@ xx(lvchange,
"\t[--version]" "\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
- autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
+ alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG,
persistent_ARG, readahead_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
test_ARG)
@@ -78,6 +79,7 @@ xx(lvcreate,
"lvcreate " "\n"
"\t[-A|--autobackup {y|n}]\n"
"\t[--addtag Tag]\n"
+ "\t[--alloc AllocationType]\n"
"\t[-C|--contiguous {y|n}]\n"
"\t[-d|--debug]\n"
"\t[-h|-?|--help]\n"
@@ -99,6 +101,7 @@ xx(lvcreate,
"\t[-c|--chunksize]\n"
"\t[-A|--autobackup {y|n}]\n"
"\t[--addtag Tag]\n"
+ "\t[--alloc AllocationType]\n"
"\t[-C|--contiguous {y|n}]\n"
"\t[-d|--debug]\n"
"\t[-h|-?|--help]\n"
@@ -114,10 +117,10 @@ xx(lvcreate,
"\t[--version]\n"
"\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
- autobackup_ARG, chunksize_ARG, contiguous_ARG, extents_ARG, major_ARG,
- minor_ARG, name_ARG, permission_ARG, persistent_ARG, readahead_ARG, size_ARG,
- snapshot_ARG, stripes_ARG, stripesize_ARG, addtag_ARG, test_ARG, type_ARG,
- zero_ARG)
+ addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
+ extents_ARG, major_ARG, minor_ARG, name_ARG, permission_ARG,
+ persistent_ARG, readahead_ARG, size_ARG, snapshot_ARG, stripes_ARG,
+ stripesize_ARG, test_ARG, type_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",
@@ -160,6 +163,7 @@ xx(lvextend,
"Add space to a logical volume",
"lvextend\n"
"\t[-A|--autobackup y|n]\n"
+ "\t[--alloc AllocationType]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
@@ -171,7 +175,7 @@ xx(lvextend,
"\t[--version]" "\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
- autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
+ alloc_ARG, autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
stripesize_ARG, test_ARG, type_ARG)
xx(lvmchange,
@@ -266,6 +270,7 @@ xx(lvresize,
"Resize a logical volume",
"lvresize\n"
"\t[-A|--autobackup y|n]\n"
+ "\t[--alloc AllocationType]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
@@ -277,8 +282,8 @@ xx(lvresize,
"\t[--version]" "\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
- autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
- test_ARG, type_ARG)
+ alloc_ARG, autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
+ stripesize_ARG, test_ARG, type_ARG)
xx(lvs,
"Display information about logical volumes",
@@ -536,6 +541,7 @@ xx(vgchange,
"Change volume group attributes",
"vgchange" "\n"
"\t[-A|--autobackup {y|n}] " "\n"
+ "\t[--alloc AllocationType] " "\n"
"\t[-P|--partial] " "\n"
"\t[-d|--debug] " "\n"
"\t[-h|--help] " "\n"
@@ -551,9 +557,9 @@ xx(vgchange,
"\t --deltag Tag}\n"
"\t[VolumeGroupName...]\n",
- allocation_ARG, autobackup_ARG, available_ARG, ignorelockingfailure_ARG,
- logicalvolume_ARG, partial_ARG, resizeable_ARG, resizable_ARG, deltag_ARG,
- addtag_ARG, test_ARG, uuid_ARG)
+ addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
+ deltag_ARG, ignorelockingfailure_ARG, logicalvolume_ARG, partial_ARG,
+ resizeable_ARG, resizable_ARG, test_ARG, uuid_ARG)
xx(vgck,
"Check the consistency of volume group(s)",
@@ -586,6 +592,7 @@ xx(vgcreate,
"vgcreate" "\n"
"\t[-A|--autobackup {y|n}] " "\n"
"\t[--addtag Tag] " "\n"
+ "\t[--alloc AllocationType] " "\n"
"\t[-d|--debug]" "\n"
"\t[-h|--help]" "\n"
"\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n"
@@ -597,8 +604,8 @@ xx(vgcreate,
"\t[--version] " "\n"
"\tVolumeGroupName PhysicalVolume [PhysicalVolume...]\n",
- autobackup_ARG, maxlogicalvolumes_ARG, maxphysicalvolumes_ARG,
- metadatatype_ARG, physicalextentsize_ARG, addtag_ARG, test_ARG)
+ addtag_ARG, alloc_ARG, autobackup_ARG, maxlogicalvolumes_ARG,
+ maxphysicalvolumes_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG)
xx(vgdisplay,
"Display volume group information",
diff --git a/tools/lvchange.c b/tools/lvchange.c
index a80b043e..df81e365 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -117,45 +117,30 @@ static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
return 1;
}
-static int lvchange_contiguous(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
{
int want_contiguous = 0;
+ alloc_policy_t alloc;
- if (strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"))
- want_contiguous = 1;
+ want_contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
+ alloc = want_contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
+ alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, alloc);
- if (want_contiguous && lv->alloc == ALLOC_CONTIGUOUS) {
+ if (alloc == lv->alloc) {
log_error("Allocation policy of logical volume \"%s\" is "
- "already contiguous", lv->name);
+ "already %s", lv->name, get_alloc_string(alloc));
return 0;
}
- if (!want_contiguous && lv->alloc != ALLOC_CONTIGUOUS) {
- log_error
- ("Allocation policy of logical volume \"%s\" is already"
- " not contiguous", lv->name);
- return 0;
- }
+ lv->alloc = alloc;
-/******** FIXME lv_check_contiguous?
- if (want_contiguous)
- && (ret = lv_check_contiguous(vg, lv_index + 1)) == FALSE) {
- log_error("No contiguous logical volume \"%s\"", lv->name);
- return 0;
-*********/
+ /* FIXME If contiguous, check existing extents already are */
- if (want_contiguous) {
- lv->alloc = ALLOC_CONTIGUOUS;
- log_verbose("Setting contiguous allocation policy for \"%s\"",
- lv->name);
- } else {
- lv->alloc = ALLOC_DEFAULT;
- log_verbose("Reverting to default allocation policy for \"%s\"",
- lv->name);
- }
+ log_verbose("Setting contiguous allocation policy for \"%s\" to %s",
+ lv->name, get_alloc_string(alloc));
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
+
if (!vg_write(lv->vg)) {
stack;
return 0;
@@ -170,7 +155,6 @@ static int lvchange_contiguous(struct cmd_context *cmd,
}
return 1;
-
}
static int lvchange_readahead(struct cmd_context *cmd,
@@ -365,7 +349,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!(lv->vg->status & LVM_WRITE) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
- arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG))) {
+ arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
+ arg_count(cmd, alloc_ARG))) {
log_error("Only -a permitted with read-only volume "
"group \"%s\"", lv->vg->name);
return EINVALID_CMD_LINE;
@@ -373,7 +358,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_origin(lv) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
- arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG))) {
+ arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
+ arg_count(cmd, alloc_ARG))) {
log_error("Can't change logical volume \"%s\" under snapshot",
lv->name);
return ECMD_FAILED;
@@ -401,11 +387,11 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* allocation policy change */
- if (arg_count(cmd, contiguous_ARG)) {
+ if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
if (!archived && !archive(lv->vg))
return ECMD_FAILED;
archived = 1;
- doit += lvchange_contiguous(cmd, lv);
+ doit += lvchange_alloc(cmd, lv);
}
/* read ahead sector change */
@@ -461,9 +447,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
&& !arg_count(cmd, permission_ARG) && !arg_count(cmd, readahead_ARG)
&& !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG)
&& !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG)
- && !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)) {
+ && !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)
+ && !arg_count(cmd, alloc_ARG)) {
log_error("One or more of -a, -C, -j, -m, -M, -p, -r, "
- "--refresh, --addtag or --deltag required");
+ "--refresh, --alloc, --addtag or --deltag required");
return EINVALID_CMD_LINE;
}
@@ -471,7 +458,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) ||
- arg_count(cmd, refresh_ARG))) {
+ arg_count(cmd, refresh_ARG) || arg_count(cmd, alloc_ARG))) {
log_error("Only -a permitted with --ignorelockingfailure");
return EINVALID_CMD_LINE;
}
@@ -492,6 +479,11 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
+ if (arg_count(cmd, contiguous_ARG) && arg_count(cmd, alloc_ARG)) {
+ log_error("Only one of --alloc and --contiguous permitted");
+ return EINVALID_CMD_LINE;
+ }
+
return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
&lvchange_single);
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 3e00509d..10ff466b 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -21,7 +21,6 @@ struct lvcreate_params {
/* flags */
int snapshot;
int zero;
- int contiguous;
int major;
int minor;
@@ -43,6 +42,7 @@ struct lvcreate_params {
uint32_t permission;
uint32_t read_ahead;
+ alloc_policy_t alloc;
int pv_count;
char **pvs;
@@ -217,6 +217,8 @@ static int _read_stripe_params(struct lvcreate_params *lp,
static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
+ int contiguous;
+
memset(lp, 0, sizeof(*lp));
/*
@@ -269,9 +271,18 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
lp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
/*
- * Contiguous ?
+ * Alloc policy
*/
- lp->contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
+ contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n");
+
+ lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT;
+
+ lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lp->alloc);
+
+ if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) {
+ log_error("Conflicting contiguous and alloc arguments");
+ return 0;
+ }
/*
* Read ahead.
@@ -365,16 +376,12 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
uint32_t size_rest;
uint32_t status = 0;
uint64_t tmp_size;
- alloc_policy_t alloc = ALLOC_DEFAULT;
struct volume_group *vg;
struct logical_volume *lv, *org = NULL;
struct list *pvh;
const char *tag;
int consistent = 1;
- if (lp->contiguous)
- alloc = ALLOC_CONTIGUOUS;
-
status |= lp->permission | VISIBLE_LV;
/* does VG exist? */
@@ -487,13 +494,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
}
if (!(lv = lv_create_empty(vg->fid, lp->lv_name, "lvol%d",
- status, alloc, vg))) {
+ status, lp->alloc, vg))) {
stack;
return 0;
}
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes, lp->stripe_size,
- lp->mirrors, lp->extents, NULL, 0u, 0u, pvh, alloc)) {
+ lp->mirrors, lp->extents, NULL, 0u, 0u, pvh, lp->alloc)) {
stack;
return 0;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 010131f0..4117be64 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -287,6 +287,21 @@ int permission_arg(struct cmd_context *cmd, struct arg *a)
return 1;
}
+int alloc_arg(struct cmd_context *cmd, struct arg *a)
+{
+ alloc_policy_t alloc;
+
+ a->sign = SIGN_NONE;
+
+ alloc = get_alloc_from_string(a->value);
+ if (alloc == ALLOC_INVALID)
+ return 0;
+
+ a->ui_value = (uint32_t) alloc;
+
+ return 1;
+}
+
int segtype_arg(struct cmd_context *cmd, struct arg *a)
{
if (!(a->ptr = (void *) get_segtype_from_string(cmd, a->value)))
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 7ac44872..32c92304 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -115,6 +115,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
uint32_t extents_used = 0;
uint32_t size_rest;
+ alloc_policy_t alloc;
char *lock_lvid;
struct lv_list *lvl;
int consistent = 1;
@@ -170,6 +171,8 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
goto error;
}
+ alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lv->alloc);
+
if (lp->size) {
if (lp->size % vg->extent_size) {
if (lp->sign == SIGN_MINUS)
@@ -393,7 +396,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (!lv_extend(vg->fid, lv, lp->segtype, lp->stripes,
lp->stripe_size, 0u, lp->extents - lv->le_count,
- NULL, 0u, 0u, lp->pvh, lv->alloc)) {
+ NULL, 0u, 0u, lp->pvh, alloc)) {
goto error;
}
}
diff --git a/tools/tools.h b/tools/tools.h
index 0cd9b244..6433dae5 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -121,6 +121,7 @@ int permission_arg(struct cmd_context *cmd, struct arg *a);
int metadatatype_arg(struct cmd_context *cmd, struct arg *a);
int units_arg(struct cmd_context *cmd, struct arg *a);
int segtype_arg(struct cmd_context *cmd, struct arg *a);
+int alloc_arg(struct cmd_context *cmd, struct arg *a);
char yes_no_prompt(const char *prompt, ...);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 940bd6d0..8f9f99bb 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -86,6 +86,40 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
return ECMD_PROCESSED;
}
+static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)
+{
+ alloc_policy_t alloc;
+
+ alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
+
+ if (alloc == ALLOC_INHERIT) {
+ log_error("Volume Group allocation policy cannot inherit "
+ "from anything");
+ return EINVALID_CMD_LINE;
+ }
+
+ if (alloc == vg->alloc) {
+ log_error("Volume group allocation policy is already %s",
+ get_alloc_string(vg->alloc));
+ return ECMD_FAILED;
+ }
+
+ if (!archive(vg))
+ return ECMD_FAILED;
+
+ vg->alloc = alloc;
+
+ if (!vg_write(vg) || !vg_commit(vg))
+ return ECMD_FAILED;
+
+ backup(vg);
+
+ log_print("Volume group \"%s\" successfully changed", vg->name);
+
+ return ECMD_PROCESSED;
+}
+
+
static int _vgchange_resizeable(struct cmd_context *cmd,
struct volume_group *vg)
{
@@ -280,6 +314,9 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
else if (arg_count(cmd, uuid_ARG))
r = _vgchange_uuid(cmd, vg);
+ else if (arg_count(cmd, alloc_ARG))
+ r = _vgchange_alloc(cmd, vg);
+
return r;
}
@@ -288,17 +325,20 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (!
(arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
- arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG))) {
- log_error("One of -a, -l, -x, --addtag, --deltag or --uuid "
- "options required");
+ arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) +
+ arg_count(cmd, alloc_ARG))) {
+ log_error("One of -a, -l, -x, --alloc, --addtag, --deltag "
+ "or --uuid required");
return EINVALID_CMD_LINE;
}
+ /* FIXME Cope with several changes at once! */
if (arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
- arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) > 1) {
- log_error("Only one of -a, -l, -x, --addtag, --deltag or --uuid"
- " options allowed");
+ arg_count(cmd, addtag_ARG) + arg_count(cmd, alloc_ARG) +
+ arg_count(cmd, uuid_ARG) > 1) {
+ log_error("Only one of -a, -l, -x, --alloc, --addtag, --deltag "
+ "or --uuid allowed");
return EINVALID_CMD_LINE;
}
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index ca44a7c9..e073e4a4 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -25,6 +25,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
char vg_path[PATH_MAX];
struct volume_group *vg;
const char *tag;
+ alloc_policy_t alloc;
if (!argc) {
log_error("Please provide volume group name and "
@@ -40,6 +41,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
vg_name = argv[0];
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, 0);
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, 0);
+ alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_NORMAL);
+
+ if (alloc == ALLOC_INHERIT) {
+ log_error("Volume Group allocation policy cannot inherit "
+ "from anything");
+ return EINVALID_CMD_LINE;
+ }
if (!(cmd->fmt->features & FMT_UNLIMITED_VOLS)) {
if (!max_lv)
@@ -92,7 +100,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
/* Create the new VG */
- if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv,
+ if (!(vg = vg_create(cmd, vg_name, extent_size, max_pv, max_lv, alloc,
argc - 1, argv + 1)))
return ECMD_FAILED;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 692d0a7c..2ff4e93d 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -215,7 +215,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
/* Create new VG structure */
if (!(vg_to = vg_create(cmd, vg_name_to, vg_from->extent_size,
- vg_from->max_pv, vg_from->max_lv, 0, NULL)))
+ vg_from->max_pv, vg_from->max_lv,
+ vg_from->alloc, 0, NULL)))
goto error;
/* Archive vg_from before changing it */