From eb3b647ba8c6cb5f5ba14b1e263bc6f972720965 Mon Sep 17 00:00:00 2001 From: na xie Date: Tue, 15 Dec 2015 09:41:49 +0800 Subject: [PATCH] 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 --- src/tools/rbd/Utils.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index 3f6cc2a1019..7deecf215a6 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; -- 2.47.3