From: na xie Date: Tue, 15 Dec 2015 01:41:49 +0000 (+0800) Subject: check for striping parameters X-Git-Tag: v10.0.3~209^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eb3b647ba8c6cb5f5ba14b1e263bc6f972720965;p=ceph.git check for striping parameters 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 --- diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index 3f6cc2a1019c..7deecf215a6b 100644 --- a/src/tools/rbd/Utils.cc +++ b/src/tools/rbd/Utils.cc @@ -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;