New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rbd: additional validation for striping parameters #6914
Conversation
@@ -772,11 +772,6 @@ int set_stripe_unit_count(cls_method_context_t hctx, bufferlist *in, bufferlist | |||
CLS_ERR("failed to read the order off of disk: %s", cpp_strerror(r).c_str()); | |||
return r; | |||
} | |||
if ((1ull << order) % stripe_unit || stripe_unit > (1ull << order)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep this check too, since librbd will still use it when not called from /usr/bin/rbd
@jdurgin thanks, I have modified them |
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>
@dachary OK, it succeed |
} 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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if stripe_unit == 1 && stripe_unit == 0
? Divide by zero would result.
if ((stripe_unit != 0 && stripe_count == 0) ||
(stripe_unit == 0 && stripe_count != 0)) {
std::cerr << "must specify both (or neither) of stripe-unit and stripe-count"
<< std::endl;
return -EINVAL;
} 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;
} |
Indeed -- it was cut off in the snippet. 👍 |
@dillaman |
rbd: additional validation for striping parameters Reviewed-by: Jason Dillaman <dillaman@redhat.com>
stripe_unit is same to object size or stripe_count is equal to 1,the remainder for it is misleading.
checking for striping parameters should be as much as possible int the front of processing.
Signed-off-by: Na Xie xie.na@h3c.com