summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinz Mauelshagen <heinzm@redhat.com>2016-07-13 21:44:06 +0200
committerHeinz Mauelshagen <heinzm@redhat.com>2016-07-13 21:45:49 +0200
commit3928c96a37941d765bf467d82502cd2aec7fd809 (patch)
tree2bcf70bfa442d9de09a6950da69734c0cda62e3d
parent26f3b321f92f49fe20749cb09727f0908867b534 (diff)
downloadlvm2-3928c96a37941d765bf467d82502cd2aec7fd809.tar.gz
lvcreate: raid0 needs default number of stripes
raid0/raid0_meta type LVs don't have a default number of stripes when created without '-i/--stripes Stripes' whereas other raid types have one. Patch sets the default for raid0/raid0_meta to 2 stripes. The default amount of stripes for raid4/5/10 is changed to 2 and for raid6 to 3 rather than using all PVs in the VG or those provided on the command line. This is to avoid unintended high number of stripes in case of many PVs. To select a different amount of stripes from the default, use 'lvcreate -i/--stripes Stripes'. - resolves rhbz1354650
-rw-r--r--tools/lvcreate.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 0dd9b1ec1..6eca8f206 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -458,17 +458,29 @@ static int _read_mirror_params(struct cmd_context *cmd,
static int _read_raid_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- if ((lp->stripes < 2) && segtype_is_raid10(lp->segtype)) {
- if (arg_is_set(cmd, stripes_ARG)) {
- /* User supplied the bad argument */
- log_error("Segment type 'raid10' requires 2 or more stripes.");
- return 0;
- }
- /* No stripe argument was given - default to 2 */
- lp->stripes = 2;
- lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
+ if (lp->stripes < 2) {
+ if (segtype_is_raid10(lp->segtype)) {
+ if (arg_is_set(cmd, stripes_ARG)) {
+ /* User supplied the bad argument */
+ log_error("Segment type 'raid10' requires 2 or more stripes.");
+ return 0;
+ }
+ /* No stripe argument was given - default to 2 */
+ /* FIXME: this needs to change to 3 once we support odd numbers of stripes */
+ lp->stripes = 2;
+ } else if (segtype_is_any_raid6(lp->segtype))
+ lp->stripes = 3;
+ else if (segtype_is_raid4(lp->segtype) ||
+ segtype_is_any_raid5(lp->segtype) ||
+ segtype_is_any_raid0(lp->segtype))
+ lp->stripes = 2;
+ else
+ lp->stripes = 1;
}
+ if (lp->stripes > 1)
+ lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
+
/*
* RAID1 does not take a stripe arg
*/
@@ -1219,43 +1231,31 @@ static int _check_raid_parameters(struct volume_group *vg,
struct lvcreate_params *lp,
struct lvcreate_cmdline_params *lcp)
{
- unsigned devs = lcp->pv_count ? : dm_list_size(&vg->pvs);
struct cmd_context *cmd = vg->cmd;
if (!seg_is_mirrored(lp) && !lp->stripe_size)
lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
- if (seg_is_any_raid0(lp)) {
+ if (segtype_is_any_raid0(lp->segtype) ||
+ segtype_is_raid4(lp->segtype) ||
+ segtype_is_any_raid5(lp->segtype)) {
if (lp->stripes < 2) {
- log_error("Segment type 'raid0' requires 2 or more stripes.");
+ log_error("Segment type \'%s\' requires 2 or more stripes.", lp->segtype->name);
return 0;
}
- } else if (!seg_is_mirrored(lp)) {
- /*
- * If number of devices was not supplied, we can infer from
- * the PVs given.
- */
- if (!arg_is_set(cmd, stripes_ARG) &&
- (devs > 2 * lp->segtype->parity_devs))
- lp->stripes = devs - lp->segtype->parity_devs;
-
- if (lp->stripes <= lp->segtype->parity_devs) {
- log_error("Number of stripes must be at least %d for %s",
- lp->segtype->parity_devs + 1,
- lp->segtype->name);
+ } else if (segtype_is_any_raid6(lp->segtype)) {
+ if (lp->stripes < 3) {
+ log_error("Segment type \'%s\' requires 3 or more stripes.", lp->segtype->name);
return 0;
}
- } else if (segtype_is_any_raid0(lp->segtype) ||
- segtype_is_raid10(lp->segtype)) {
- if (!arg_is_set(cmd, stripes_ARG))
- lp->stripes = devs / lp->mirrors;
+ } else if (segtype_is_raid10(lp->segtype)) {
if (lp->stripes < 2) {
- log_error("Unable to create RAID(1)0 LV: "
- "insufficient number of devices.");
+ log_error("Unable to create %s LV: "
+ "insufficient number of devices.", lp->segtype->name);
return 0;
}
}
- /* 'mirrors' defaults to 2 - not the number of PVs supplied */
+ /* 'mirrors' defaults to 2 */
return 1;
}