]> sourceware.org Git - lvm2.git/commitdiff
Accept sizes with --readahead argument.
authorAlasdair Kergon <agk@redhat.com>
Wed, 14 Nov 2007 00:08:25 +0000 (00:08 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 14 Nov 2007 00:08:25 +0000 (00:08 +0000)
Store size arguments as sectors internally.

WHATS_NEW
lib/report/report.c
tools/lvconvert.c
tools/lvcreate.c
tools/lvmcmdline.c
tools/lvresize.c
tools/pvcreate.c
tools/pvresize.c
tools/vgchange.c
tools/vgconvert.c
tools/vgcreate.c

index 46f1878abbb385512ec8bbde6842a03a29559911..fdb4aaa5e2d08df051d8c25f8c1ebb807ae1963a 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.02.29 -
 ==================================
+  Accept sizes with --readahead argument.
+  Store size arguments as sectors internally.
   Attempt to remove incomplete LVs with lvcreate zeroing/activation problems.
   Add read_ahead activation code.
   Add activation/readahead configuration option and FMT_RESTRICTED_READAHEAD.
index 58c230c0b341d73d6b27572f6971d8c395aff4c5..efe3f2ca198d40e9c3ea2d86f100e12a333a24e2 100644 (file)
@@ -566,30 +566,27 @@ static int _lvreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
                             const void *data, void *private __attribute((unused)))
 {
        const struct logical_volume *lv = (const struct logical_volume *) data;
-       uint64_t size;
 
        if (lv->read_ahead == DM_READ_AHEAD_AUTO) {
                dm_report_field_set_value(field, "auto", &_minusone);
                return 1;
        }
 
-       size = (uint64_t) lv->read_ahead;
-
-       return _size64_disp(rh, mem, field, &size, private);
+       return _size32_disp(rh, mem, field, &lv->read_ahead, private);
 }
 
 static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
                              struct dm_report_field *field,
                              const void *data,
-                             void *private __attribute((unused)))
+                             void *private)
 {
        const struct logical_volume *lv = (const struct logical_volume *) data;
        struct lvinfo info;
 
-       if (lv_info(lv->vg->cmd, lv, &info, 0, 1) && info.exists)
-               return dm_report_field_int(rh, field, &info.read_ahead);
+       if (!lv_info(lv->vg->cmd, lv, &info, 0, 1) || !info.exists)
+               return dm_report_field_uint64(rh, field, &_minusone);
 
-       return dm_report_field_uint64(rh, field, &_minusone);
+       return _size32_disp(rh, mem, field, &info.read_ahead, private);
 }
 
 static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,
index 293f49b13480d68690002b9cb180691f2a0f5fe8..e3cc34f18c0a1620b4b00729631581e262f8eed6 100644 (file)
@@ -135,7 +135,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
                        log_error("Negative chunk size is invalid");
                        return 0;
                }
-               lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
+               lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
                if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
                    (lp->chunk_size & (lp->chunk_size - 1))) {
                        log_error("Chunk size must be a power of 2 in the "
@@ -175,8 +175,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
                                log_error("Negative regionsize is invalid");
                                return 0;
                        }
-                       lp->region_size = 2 * arg_uint_value(cmd,
-                                                            regionsize_ARG, 0);
+                       lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
                } else {
                        region_size = 2 * find_config_tree_int(cmd,
                                                "activation/mirror_region_size",
index fc68d4f4361088069fe6a3158e08295709337504..2976cadb08166cce198f91559c504d2653b35f8e 100644 (file)
@@ -173,7 +173,7 @@ static int _read_size_params(struct lvcreate_params *lp,
                        log_error("Negative size is invalid");
                        return 0;
                }
-               lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
+               lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
                lp->percent = PERCENT_NONE;
        }
 
@@ -195,7 +195,7 @@ static int _validate_stripe_params(struct cmd_context *cmd,
        if (lp->stripes > 1 && !lp->stripe_size) {
                lp->stripe_size = find_config_tree_int(cmd,
                                                  "metadata/stripesize",
-                                                 DEFAULT_STRIPESIZE) * 2;
+                                                 DEFAULT_STRIPESIZE);
                log_print("Using default stripesize %s",
                          display_size(cmd, (uint64_t) lp->stripe_size));
        }
@@ -230,12 +230,12 @@ static int _read_stripe_params(struct lvcreate_params *lp,
                        return 0;
                }
                /* Check to make sure we won't overflow lp->stripe_size */
-               if(arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
+               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 = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
+               lp->stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
        }
 
 
@@ -310,7 +310,7 @@ static int _read_mirror_params(struct lvcreate_params *lp,
                        log_error("Negative regionsize is invalid");
                        return 0;
                }
-               lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
+               lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
        } else {
                region_size = 2 * find_config_tree_int(cmd,
                                        "activation/mirror_region_size",
@@ -375,7 +375,7 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
                        log_error("Negative chunk size is invalid");
                        return 0;
                }
-               lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
+               lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
                if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
                    (lp->chunk_size & (lp->chunk_size - 1))) {
                        log_error("Chunk size must be a power of 2 in the "
index ca77e242c8da6713624e8eb9d9b388238864da7b..9ef88b877997683c004c2a155b7cfe2b36cc691c 100644 (file)
@@ -169,6 +169,7 @@ static int _get_int_arg(struct arg *a, char **ptr)
        return 1;
 }
 
+/* Size stored in sectors */
 static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a, int factor)
 {
        char *ptr;
@@ -211,6 +212,8 @@ static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg *
 
                while (i-- > 0)
                        v *= 1024;
+
+               v *= 2;
        } else
                v *= factor;
 
@@ -224,12 +227,12 @@ static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg *
 
 int size_kb_arg(struct cmd_context *cmd, struct arg *a)
 {
-       return _size_arg(cmd, a, 1);
+       return _size_arg(cmd, a, 2);
 }
 
 int size_mb_arg(struct cmd_context *cmd, struct arg *a)
 {
-       return _size_arg(cmd, a, 1024);
+       return _size_arg(cmd, a, 2048);
 }
 
 int int_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
@@ -377,9 +380,6 @@ int segtype_arg(struct cmd_context *cmd, struct arg *a)
  */
 int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
 {
-       if (int_arg(cmd, a))
-               return 1;
-
        if (!strcasecmp(a->value, "auto")) {
                a->ui_value = DM_READ_AHEAD_AUTO;
                return 1;
@@ -390,7 +390,13 @@ int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
                return 1;
        }
 
-       return 0;
+       if (!_size_arg(cmd, a, 1))
+               return 0;
+
+       if (a->sign == SIGN_MINUS)
+               return 0;
+
+       return 1;
 }
 
 static void __alloc(int size)
index 3ddf4df883a53af18bd74c08a6fc132c698fa224..5ba1706fc75b45ece1d829783bdf39c0cc2d6b6a 100644 (file)
@@ -55,7 +55,7 @@ static int validate_stripesize(struct cmd_context *cmd,
                return 0;
        }
 
-       if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
+       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;
@@ -63,16 +63,15 @@ static int validate_stripesize(struct cmd_context *cmd,
 
        if (!(vg->fid->fmt->features & FMT_SEGMENTS))
                log_warn("Varied stripesize not supported. Ignoring.");
-       else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
+       else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size * 2) {
                log_error("Reducing stripe size %s to maximum, "
                          "physical extent size %s",
                          display_size(cmd,
-                                      (uint64_t) arg_uint_value(cmd, stripesize_ARG, 0) * 2),
+                                      (uint64_t) arg_uint_value(cmd, stripesize_ARG, 0)),
                          display_size(cmd, (uint64_t) vg->extent_size));
                lp->stripe_size = vg->extent_size;
        } else
-               lp->stripe_size = 2 * arg_uint_value(cmd,
-                                                    stripesize_ARG, 0);
+               lp->stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
 
        if (lp->mirrors) {
                log_error("Mirrors and striping cannot be combined yet.");
@@ -208,7 +207,7 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
 
        /* Size returned in kilobyte units; held in sectors */
        if (arg_count(cmd, size_ARG)) {
-               lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
+               lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
                lp->sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
                lp->percent = PERCENT_NONE;
        }
index 4220efa88b4f5549bcbfb6dd5f48013cac62e78e..766c9d37952889ddf61dab05db9bf969e5fe582b 100644 (file)
@@ -186,14 +186,13 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
                log_error("Physical volume size may not be negative");
                goto error;
        }
-       size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0)) * 2;
+       size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
 
        if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
                log_error("Metadata size may not be negative");
                goto error;
        }
-       pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0))
-           * 2;
+       pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
        if (!pvmetadatasize)
                pvmetadatasize = find_config_tree_int(cmd,
                                                 "metadata/pvmetadatasize",
index 2747473fca7f8dc9234193b16f57bceb4382bd7c..18494a2ca0b702d0da7dffa0211272487c6b4567 100644 (file)
@@ -56,7 +56,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
        }
 
        params.new_size = arg_uint64_value(cmd, physicalvolumesize_ARG,
-                                          UINT64_C(0)) * 2;
+                                          UINT64_C(0));
 
        params.done = 0;
        params.total = 0;
index 08e7147bb8c488f8fda8dbeee078915092417094..7503c498e56464dd23b9893fa7c97c88b72e4563 100644 (file)
@@ -388,7 +388,7 @@ static int _vgchange_pesize(struct cmd_context *cmd, struct volume_group *vg)
                return EINVALID_CMD_LINE;
        }
 
-       extent_size = arg_uint_value(cmd, physicalextentsize_ARG, 0) * 2;
+       extent_size = arg_uint_value(cmd, physicalextentsize_ARG, 0);
        if (!extent_size) {
                log_error("Physical extent size may not be zero");
                return EINVALID_CMD_LINE;
index a654462a0e84f4b856ad2d02f8714ea75111caff..8703632349a058974d8c7a3b0a4c4d7c0792fd94 100644 (file)
@@ -61,7 +61,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
                }
 
                pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG,
-                                                 UINT64_C(0)) * 2;
+                                                 UINT64_C(0));
                if (!pvmetadatasize)
                        pvmetadatasize =
                            find_config_tree_int(cmd,
index 247b97813d46dc6d840d3bfa363f7833b7526143..736c874339afbbdf75d3a2d6a1ad622dae8b582b 100644 (file)
@@ -77,7 +77,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
 
        /* Units of 512-byte sectors */
        extent_size =
-           arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
+           arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT);
 
        if (!extent_size) {
                log_error("Physical extent size may not be zero");
This page took 0.06018 seconds and 5 git commands to generate.