]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: support overriding image data pool when creating images
authorJason Dillaman <dillaman@redhat.com>
Thu, 6 Oct 2016 18:31:27 +0000 (14:31 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 10 Oct 2016 14:41:57 +0000 (10:41 -0400)
Fixes: http://tracker.ceph.com/issues/17424
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/cli/rbd/help.t
src/tools/rbd/ArgumentTypes.cc
src/tools/rbd/ArgumentTypes.h
src/tools/rbd/Utils.cc

index 2af8912fa6363f43a001f7b6a72be98a23ce1681..ea9e6eeacad3a080520208df370440680a84ca8d 100644 (file)
                    [--object-size <object-size>] 
                    [--image-feature <image-feature>] [--image-shared] 
                    [--stripe-unit <stripe-unit>] [--stripe-count <stripe-count>] 
+                   [--data-pool <data-pool>] 
                    [--journal-splay-width <journal-splay-width>] 
                    [--journal-object-size <journal-object-size>] 
                    [--journal-pool <journal-pool>] 
     --image-shared            shared image
     --stripe-unit arg         stripe unit
     --stripe-count arg        stripe count
+    --data-pool arg           data pool
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects
     --journal-pool arg        pool for journal objects
                   [--object-size <object-size>] 
                   [--image-feature <image-feature>] [--image-shared] 
                   [--stripe-unit <stripe-unit>] [--stripe-count <stripe-count>] 
+                  [--data-pool <data-pool>] 
                   [--journal-splay-width <journal-splay-width>] 
                   [--journal-object-size <journal-object-size>] 
                   [--journal-pool <journal-pool>] [--no-progress] 
     --image-shared               shared image
     --stripe-unit arg            stripe unit
     --stripe-count arg           stripe count
+    --data-pool arg              data pool
     --journal-splay-width arg    number of active journal objects
     --journal-object-size arg    size of journal objects
     --journal-pool arg           pool for journal objects
                     [--order <order>] [--object-size <object-size>] 
                     [--image-feature <image-feature>] [--image-shared] 
                     [--stripe-unit <stripe-unit>] 
-                    [--stripe-count <stripe-count>] 
+                    [--stripe-count <stripe-count>] [--data-pool <data-pool>] 
                     [--journal-splay-width <journal-splay-width>] 
                     [--journal-object-size <journal-object-size>] 
                     [--journal-pool <journal-pool>] --size <size> 
     --image-shared            shared image
     --stripe-unit arg         stripe unit
     --stripe-count arg        stripe count
+    --data-pool arg           data pool
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects
     --journal-pool arg        pool for journal objects
                     [--order <order>] [--object-size <object-size>] 
                     [--image-feature <image-feature>] [--image-shared] 
                     [--stripe-unit <stripe-unit>] 
-                    [--stripe-count <stripe-count>] 
+                    [--stripe-count <stripe-count>] [--data-pool <data-pool>] 
                     [--journal-splay-width <journal-splay-width>] 
                     [--journal-object-size <journal-object-size>] 
                     [--journal-pool <journal-pool>] [--no-progress] 
     --image-shared            shared image
     --stripe-unit arg         stripe unit
     --stripe-count arg        stripe count
+    --data-pool arg           data pool
     --journal-splay-width arg number of active journal objects
     --journal-object-size arg size of journal objects
     --journal-pool arg        pool for journal objects
index 910aef041fa18e0d703559d641e79f103de04e60..9ec3ec8a3f8bf76716a4431385f9317aa1504caf 100644 (file)
@@ -268,7 +268,8 @@ void add_create_image_options(po::options_description *opt,
      ("image features\n" + get_short_features_help(true)).c_str())
     (IMAGE_SHARED.c_str(), po::bool_switch(), "shared image")
     (IMAGE_STRIPE_UNIT.c_str(), po::value<uint64_t>(), "stripe unit")
-    (IMAGE_STRIPE_COUNT.c_str(), po::value<uint64_t>(), "stripe count");
+    (IMAGE_STRIPE_COUNT.c_str(), po::value<uint64_t>(), "stripe count")
+    (IMAGE_DATA_POOL.c_str(), po::value<std::string>(), "data pool");
 
   add_create_journal_options(opt);
 }
index 016a91bf5ea3825b80a5185ce2bca6d664ed1c3f..325b0418b659ccde93bb99ec51c124f5b8bdb81c 100644 (file)
@@ -69,6 +69,7 @@ static const std::string IMAGE_SHARED("image-shared");
 static const std::string IMAGE_SIZE("size");
 static const std::string IMAGE_STRIPE_UNIT("stripe-unit");
 static const std::string IMAGE_STRIPE_COUNT("stripe-count");
+static const std::string IMAGE_DATA_POOL("data-pool");
 
 static const std::string JOURNAL_OBJECT_SIZE("journal-object-size");
 static const std::string JOURNAL_SPLAY_WIDTH("journal-splay-width");
index e5c8fc6bd47acf4f1c346144de1402665bac3d86..679de96964cc6c2c3f7e1697dc5cbbf26cc2bfda 100644 (file)
@@ -519,6 +519,7 @@ int get_image_options(const boost::program_options::variables_map &vm,
                      bool get_format, librbd::ImageOptions *opts) {
   uint64_t order = 0, stripe_unit = 0, stripe_count = 0, object_size = 0;
   uint64_t features = 0, features_clear = 0, features_set = 0;
+  std::string data_pool;
   bool order_specified = true;
   bool features_specified = false;
   bool features_clear_specified = false;
@@ -560,6 +561,10 @@ int get_image_options(const boost::program_options::variables_map &vm,
     }
   }
 
+  if (vm.count(at::IMAGE_DATA_POOL)) {
+    data_pool = vm[at::IMAGE_DATA_POOL].as<std::string>();
+  }
+
   if (get_format) {
     uint64_t format = 0;
     bool format_specified = false;
@@ -597,6 +602,17 @@ int get_image_options(const boost::program_options::variables_map &vm,
       }
     }
 
+    if (!data_pool.empty()) {
+      if (format_specified && format == 1) {
+        std::cerr << "rbd: data pool not allowed with format 1; "
+                  << "use --image-format 2" << std::endl;
+        return -EINVAL;
+      } else {
+        format = 2;
+        format_specified = true;
+      }
+    }
+
     if (format_specified) {
       int r = g_conf->set_val("rbd_default_format", stringify(format));
       assert(r == 0);
@@ -617,7 +633,9 @@ int get_image_options(const boost::program_options::variables_map &vm,
     opts->set(RBD_IMAGE_OPTION_STRIPE_UNIT, stripe_unit);
     opts->set(RBD_IMAGE_OPTION_STRIPE_COUNT, stripe_count);
   }
-
+  if (!data_pool.empty()) {
+    opts->set(RBD_IMAGE_OPTION_DATA_POOL, data_pool);
+  }
   int r = get_journal_options(vm, opts);
   if (r < 0) {
     return r;