]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: support size suffixes for size-based options 5481/head
authorVikhyat Umrao <vumrao@redhat.com>
Wed, 5 Aug 2015 16:55:35 +0000 (22:25 +0530)
committerVikhyat Umrao <vumrao@redhat.com>
Thu, 6 Aug 2015 15:10:51 +0000 (20:40 +0530)
This patch will provide support for size suffixes for
below given options:

--stripe-unit <size in B/K/M>
--io-size <size in B/K/M/G/T>
--io-total <size in B/K/M/G/T>

Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
doc/man/8/rbd.rst
src/rbd.cc
src/test/cli-integration/rbd/defaults.t
src/test/cli-integration/rbd/formatted-output.t
src/test/cli/rbd/help.t

index e93bffcfb097a8d6a344c829bf4ba7073a570a6f..d7eb72d7c9d2295a5674eafaa6bab58ff5e1a39a 100644 (file)
@@ -70,9 +70,9 @@ Parameters
    Specifies the object size expressed as a number of bits, such that
    the object size is ``1 << order``. The default is 22 (4 MB).
 
-.. option:: --stripe-unit size-in-bytes
+.. option:: --stripe-unit size-in-B/K/M
 
-   Specifies the stripe unit size in bytes.  See striping section (below) for more details.
+   Specifies the stripe unit size in B/K/M.  See striping section (below) for more details.
 
 .. option:: --stripe-count num
 
@@ -176,11 +176,11 @@ Commands
   If image is a clone, information about its parent is also displayed.
   If a snapshot is specified, whether it is protected is shown as well.
 
-:command:`create` (-s | --size *size-in-M/G/T*) [--image-format *format-id*] [--order *bits*] [--stripe-unit *size-in-bytes* --stripe-count *num*] [--image-feature *feature-name*]... [--image-shared] *image-spec*
+:command:`create` (-s | --size *size-in-M/G/T*) [--image-format *format-id*] [--order *bits*] [--stripe-unit *size-in-B/K/M* --stripe-count *num*] [--image-feature *feature-name*]... [--image-shared] *image-spec*
   Will create a new rbd image. You must also specify the size via --size.  The
   --stripe-unit and --stripe-count arguments are optional, but must be used together.
 
-:command:`clone` [--order *bits*] [--stripe-unit *size-in-bytes* --stripe-count *num*] [--image-feature *feature-name*]... [--image-shared] *parent-snap-spec* *child-image-spec*
+:command:`clone` [--order *bits*] [--stripe-unit *size-in-B/K/M* --stripe-count *num*] [--image-feature *feature-name*] [--image-shared] *parent-snap-spec* *child-image-spec*
   Will create a clone (copy-on-write child) of the parent snapshot.
   Object order will be identical to that of the parent image unless
   specified. Size will be the same as the parent snapshot. The --stripe-unit
@@ -214,7 +214,7 @@ Commands
 :command:`export` (*image-spec* | *snap-spec*) [*dest-path*]
   Exports image to dest path (use - for stdout).
 
-:command:`import` [--image-format *format-id*] [--order *bits*] [--stripe-unit *size-in-bytes* --stripe-count *num*] [--image-feature *feature-name*]... [--image-shared] *src-path* [*image-spec*]
+:command:`import` [--image-format *format-id*] [--order *bits*] [--stripe-unit *size-in-B/K/M* --stripe-count *num*] [--image-feature *feature-name*]... [--image-shared] *src-path* [*image-spec*]
   Creates a new image and imports its data from path (use - for
   stdin).  The import operation will try to create sparse rbd images 
   if possible.  For import from stdin, the sparsification unit is
@@ -343,9 +343,9 @@ Commands
   Release a lock on an image. The lock id and locker are
   as output by lock ls.
 
-:command:`bench-write` [--io-size *size-in-bytes*] [--io-threads *num-ios-in-flight*] [--io-total *total-bytes-to-write*] [--io-pattern seq | rand] *image-spec*
+:command:`bench-write` [--io-size *size-in-B/K/M/G/T*] [--io-threads *num-ios-in-flight*] [--io-total *total-size-to-write-in-B/K/M/G/T*] [--io-pattern seq | rand] *image-spec*
   Generate a series of writes to the image and measure the write throughput and
-  latency.  Defaults are: --io-size 4096, --io-threads 16, --io-total 1GB,
+  latency.  Defaults are: --io-size 4096, --io-threads 16, --io-total 1G,
   --io-pattern seq.
 
 Image and snap specs
@@ -491,7 +491,7 @@ To create an image and a clone from it::
 
 To create an image with a smaller stripe_unit (to better distribute small writes in some workloads)::
 
-       rbd create mypool/myimage --size 102400 --stripe-unit 65536 --stripe-count 16
+       rbd create mypool/myimage --size 102400 --stripe-unit 65536B --stripe-count 16
 
 To change an image from one image format to another, export it and then
 import it as the desired image format::
index ea48e46ebd407bb36b431dd146d6523e56de8aa8..ced784cb2b45a9f482e09a4a98fe6eddeb29b1ad 100644 (file)
@@ -161,10 +161,10 @@ void usage()
 "  lock add <image-spec> <id> [--shared <tag>] take a lock called id on an image\n"
 "  lock remove <image-spec> <id> <locker>      release a lock on an image\n"
 "  bench-write <image-spec>                    simple write benchmark\n"
-"                 --io-size <bytes>              write size\n"
-"                 --io-threads <num>             ios in flight\n"
-"                 --io-total <bytes>             total bytes to write\n"
-"                 --io-pattern <seq|rand>        write pattern\n"
+"               --io-size <size in B/K/M/G/T>    write size\n"
+"               --io-threads <num>               ios in flight\n"
+"               --io-total <size in B/K/M/G/T>   total size to write\n"
+"               --io-pattern <seq|rand>          write pattern\n"
 "\n"
 "<image-spec> is [<pool-name>]/<image-name>,\n"
 "<snap-spec> is [<pool-name>]/<image-name>@<snap-name>,\n"
@@ -188,7 +188,7 @@ void usage()
 "                                     use multiple times to enable multiple features\n"
 "  --image-shared                     image will be used concurrently (disables\n"
 "                                     RBD exclusive lock and dependent features)\n"
-"  --stripe-unit <size-in-bytes>      size (in bytes) of a block of data\n"
+"  --stripe-unit <size in B/K/M>      size of a block of data\n"
 "  --stripe-count <num>               number of consecutive objects in a stripe\n"
 "  --id <username>                    rados user (without 'client.'prefix) to\n"
 "                                     authenticate as\n"
@@ -3056,7 +3056,17 @@ int main(int argc, const char **argv)
       size_set = true;
     } else if (ceph_argparse_flag(args, i, "-l", "--long", (char*)NULL)) {
       lflag = true;
-    } else if (ceph_argparse_witharg(args, i, &stripe_unit, err, "--stripe-unit", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &val, err, "--stripe-unit", (char*)NULL)) {
+      if (!err.str().empty()) {
+        cerr << "rbd: " << err.str() << std::endl;
+        return EXIT_FAILURE;
+      }
+      const char *stripeval = val.c_str();
+      stripe_unit = strict_sistrtoll(stripeval, &parse_err);
+      if (!parse_err.empty()) {
+        cerr << "rbd: error parsing --stripe-unit " << parse_err << std::endl;
+        return EXIT_FAILURE;
+      }
     } else if (ceph_argparse_witharg(args, i, &stripe_count, err, "--stripe-count", (char*)NULL)) {
     } else if (ceph_argparse_witharg(args, i, &order, err, "--order", (char*)NULL)) {
       if (!err.str().empty()) {
@@ -3067,17 +3077,33 @@ int main(int argc, const char **argv)
        cerr << "rbd: order must be between 12 (4 KB) and 25 (32 MB)" << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_witharg(args, i, &bench_io_size, err, "--io-size", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &val, err, "--io-size", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << "rbd: " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
+      const char *iosval = val.c_str();
+      bench_io_size = strict_sistrtoll(iosval, &parse_err);
+      if (!parse_err.empty()) {
+        cerr << "rbd: error parsing --io-size " << parse_err << std::endl;
+        return EXIT_FAILURE;
+      }
       if (bench_io_size == 0) {
        cerr << "rbd: io-size must be > 0" << std::endl;
        return EXIT_FAILURE;
       }
     } else if (ceph_argparse_witharg(args, i, &bench_io_threads, err, "--io-threads", (char*)NULL)) {
-    } else if (ceph_argparse_witharg(args, i, &bench_bytes, err, "--io-total", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &val, err, "--io-total", (char*)NULL)) {
+      if (!err.str().empty()) {
+       cerr << "rbd: " << err.str() << std::endl;
+       return EXIT_FAILURE;
+      }
+      const char *iotval = val.c_str();
+      bench_bytes = strict_sistrtoll(iotval, &parse_err);
+      if (!parse_err.empty()) {
+        cerr << "rbd: error parsing --io-total " << parse_err << std::endl;
+        return EXIT_FAILURE;
+      }
     } else if (ceph_argparse_witharg(args, i, &bench_pattern, "--io-pattern", (char*)NULL)) {
     } else if (ceph_argparse_witharg(args, i, &val, "--path", (char*)NULL)) {
       path = strdup(val.c_str());
index 85eefbcf374180b49eed90b27e812162d476e2ec..6ce4de658bb73aefcb01fc29bbaa01d507c3277d 100644 (file)
@@ -94,6 +94,63 @@ Plain create with various options specified via usual cli arguments
       "stripe_unit": 1048576
   }
   $ rbd rm test --no-progress
+  $ rbd create -s 1 test --image-format 2 --stripe-unit 1048576B --stripe-count 8
+  $ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
+  {
+      "block_name_prefix": "rbd_data.*",  (glob)
+      "features": [
+          "layering", 
+          "striping", 
+          "exclusive"
+      ], 
+      "format": 2, 
+      "name": "test", 
+      "object_size": 4194304, 
+      "objects": 1, 
+      "order": 22, 
+      "size": 1048576, 
+      "stripe_count": 8, 
+      "stripe_unit": 1048576
+  }
+  $ rbd rm test --no-progress
+  $ rbd create -s 1G test --image-format 2 --stripe-unit 4K --stripe-count 8
+  $ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
+  {
+      "block_name_prefix": "rbd_data.*",  (glob)
+      "features": [
+          "layering", 
+          "striping", 
+          "exclusive"
+      ], 
+      "format": 2, 
+      "name": "test", 
+      "object_size": 4194304, 
+      "objects": 256, 
+      "order": 22, 
+      "size": 1073741824, 
+      "stripe_count": 8, 
+      "stripe_unit": 4096
+  }
+  $ rbd rm test --no-progress
+  $ rbd create -s 1G test --image-format 2 --stripe-unit 1M --stripe-count 8
+  $ rbd info test --format json | python -mjson.tool | sed 's/,$/, /'
+  {
+      "block_name_prefix": "rbd_data.*",  (glob)
+      "features": [
+          "layering", 
+          "striping", 
+          "exclusive"
+      ], 
+      "format": 2, 
+      "name": "test", 
+      "object_size": 4194304, 
+      "objects": 256, 
+      "order": 22, 
+      "size": 1073741824, 
+      "stripe_count": 8, 
+      "stripe_unit": 1048576
+  }
+  $ rbd rm test --no-progress
 
 Format 2 Usual arguments with custom rbd_default_* params
 =========================================================
index 4d407b9da4299400cb9d9ec8142b48bf9a0ea238..03089039091152faceb726f9199f2bfef1e0f69e 100644 (file)
@@ -35,7 +35,7 @@ clone
   $ rbd clone bar@snap rbd_other/child
   $ rbd snap create rbd_other/child@snap
   $ rbd flatten rbd_other/child 2> /dev/null
-  $ rbd bench-write rbd_other/child --io-pattern seq --io-total 1 > /dev/null 2>&1
+  $ rbd bench-write rbd_other/child --io-pattern seq --io-total 1B > /dev/null 2>&1
 
 lock
 ====
index c0a0618e6db355bedbf3596c1df78ee15b0000ac..ad6a9ee90b524d053c47e616548bd350d6333a47 100644 (file)
     lock add <image-spec> <id> [--shared <tag>] take a lock called id on an image
     lock remove <image-spec> <id> <locker>      release a lock on an image
     bench-write <image-spec>                    simple write benchmark
-                   --io-size <bytes>              write size
-                   --io-threads <num>             ios in flight
-                   --io-total <bytes>             total bytes to write
-                   --io-pattern <seq|rand>        write pattern
+                 --io-size <size in B/K/M/G/T>    write size
+                 --io-threads <num>               ios in flight
+                 --io-total <size in B/K/M/G/T>   total size to write
+                 --io-pattern <seq|rand>          write pattern
   
   <image-spec> is [<pool-name>]/<image-name>,
   <snap-spec> is [<pool-name>]/<image-name>@<snap-name>,
@@ -98,7 +98,7 @@
                                        use multiple times to enable multiple features
     --image-shared                     image will be used concurrently (disables
                                        RBD exclusive lock and dependent features)
-    --stripe-unit <size-in-bytes>      size (in bytes) of a block of data
+    --stripe-unit <size in B/K/M>      size of a block of data
     --stripe-count <num>               number of consecutive objects in a stripe
     --id <username>                    rados user (without 'client.'prefix) to
                                        authenticate as