summaryrefslogtreecommitdiffstats
path: root/tools/lvcreate.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2010-04-13 01:54:32 +0000
committerAlasdair Kergon <agk@redhat.com>2010-04-13 01:54:32 +0000
commit68176be18ec23849e35ced364bfb923858d5dc5d (patch)
treed3b7e1238889b2d8a82af39c56f3cebfa1d3661d /tools/lvcreate.c
parent59131572d51d1d6eb3fa7e9afb5a53e5102e97c3 (diff)
downloadlvm2-68176be18ec23849e35ced364bfb923858d5dc5d.tar.gz
lvm2-68176be18ec23849e35ced364bfb923858d5dc5d.tar.xz
lvm2-68176be18ec23849e35ced364bfb923858d5dc5d.zip
Add --stripes to lvconvert too.
Diffstat (limited to 'tools/lvcreate.c')
-rw-r--r--tools/lvcreate.c71
1 files changed, 1 insertions, 70 deletions
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 83dda325..89687187 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -233,71 +233,6 @@ static int _read_size_params(struct lvcreate_params *lp,
}
/*
- * Generic stripe parameter checks.
- * FIXME: Should eventually be moved into lvm library.
- */
-static int _validate_stripe_params(struct cmd_context *cmd,
- struct lvcreate_params *lp)
-{
- if (lp->stripes == 1 && lp->stripe_size) {
- log_print("Ignoring stripesize argument with single stripe");
- lp->stripe_size = 0;
- }
-
- if (lp->stripes > 1 && !lp->stripe_size) {
- lp->stripe_size = find_config_tree_int(cmd,
- "metadata/stripesize",
- DEFAULT_STRIPESIZE) * 2;
- log_print("Using default stripesize %s",
- display_size(cmd, (uint64_t) lp->stripe_size));
- }
-
- if (lp->stripes < 1 || lp->stripes > MAX_STRIPES) {
- log_error("Number of stripes (%d) must be between %d and %d",
- lp->stripes, 1, MAX_STRIPES);
- return 0;
- }
-
- /* MAX size check is in _lvcreate */
- if (lp->stripes > 1 && (lp->stripe_size < STRIPE_SIZE_MIN ||
- lp->stripe_size & (lp->stripe_size - 1))) {
- log_error("Invalid stripe size %s",
- display_size(cmd, (uint64_t) lp->stripe_size));
- return 0;
- }
-
- return 1;
-}
-
-/* The stripe size is limited by the size of a uint32_t, but since the
- * value given by the user is doubled, and the final result must be a
- * power of 2, we must divide UINT_MAX by four and add 1 (to round it
- * up to the power of 2) */
-static int _read_stripe_params(struct lvcreate_params *lp,
- struct cmd_context *cmd)
-{
- if (arg_count(cmd, stripesize_ARG)) {
- if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
- log_error("Negative stripesize is invalid");
- return 0;
- }
- /* Check to make sure we won't overflow lp->stripe_size */
- if(arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
- log_error("Stripe size cannot be larger than %s",
- display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
- return 0;
- }
- lp->stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
- }
-
-
- if (!_validate_stripe_params(cmd, lp))
- return 0;
-
- return 1;
-}
-
-/*
* Generic mirror parameter checks.
* FIXME: Should eventually be moved into lvm library.
*/
@@ -399,10 +334,6 @@ static int _lvcreate_params(struct lvcreate_params *lp,
arg_ptr_value(cmd, type_ARG,
get_segtype_from_string(cmd, "striped"));
- lp->stripes = arg_uint_value(cmd, stripes_ARG, 1);
- if (arg_count(cmd, stripes_ARG) && lp->stripes == 1)
- log_print("Redundant stripes argument: default is 1");
-
if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) ||
arg_count(cmd, virtualsize_ARG))
lp->snapshot = 1;
@@ -484,7 +415,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, lcp, cmd) ||
- !_read_stripe_params(lp, cmd) ||
+ !get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
!_read_mirror_params(lp, cmd))
return_0;