]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
check for striping parameters 6914/head
authorna xie <xie.na@h3c.com>
Tue, 15 Dec 2015 01:41:49 +0000 (09:41 +0800)
committerna xie <xie.na@h3c.com>
Tue, 15 Dec 2015 07:57:59 +0000 (15:57 +0800)
stripe_unit is same to object size or stripe_count is equal to 1,the remainder for it is misleading.

Signed-off-by: Na Xie <xie.na@h3c.com>
src/tools/rbd/Utils.cc

index 3f6cc2a1019cda599b2d40a2c3090546f1ff69ae..7deecf215a6bf13068b061430947804916c4c3f3 100644 (file)
@@ -355,8 +355,15 @@ int get_image_options(const boost::program_options::variables_map &vm,
     std::cerr << "must specify both (or neither) of stripe-unit and stripe-count"
               << std::endl;
     return -EINVAL;
-  } else if ((stripe_unit || stripe_count) &&
-             (stripe_unit != (1ull << order) && stripe_count != 1)) {
+  } else if (stripe_unit || stripe_count) {
+    if ((1ull << order) % stripe_unit || stripe_unit >= (1ull << order)) {
+      std::cerr << "stripe unit is not a factor of the object size" << std::endl;
+      return -EINVAL;
+    }
+    if (stripe_count == 1) {
+      std::cerr << "stripe count not allowed to be 1" << std::endl;
+      return -EINVAL;
+    }
     features |= RBD_FEATURE_STRIPINGV2;
   } else {
     features &= ~RBD_FEATURE_STRIPINGV2;