ldout(cct, 10) << __func__ << " name=" << imgname << ", "
<< "size=" << size << ", opts=" << opts << dendl;
- uint64_t format = cct->_conf->rbd_default_format;
- opts.get(RBD_IMAGE_OPTION_FORMAT, &format);
+ uint64_t format;
+ if (opts.get(RBD_IMAGE_OPTION_FORMAT, &format) != 0)
+ format = cct->_conf->rbd_default_format;
bool old_format = format == 1;
uint64_t features;
}
uint64_t stripe_unit = 0;
uint64_t stripe_count = 0;
- opts.get(RBD_IMAGE_OPTION_STRIPE_UNIT, &stripe_unit);
- opts.get(RBD_IMAGE_OPTION_STRIPE_COUNT, &stripe_count);
+ if (!old_format) {
+ if (opts.get(RBD_IMAGE_OPTION_STRIPE_UNIT, &stripe_unit) != 0 || stripe_unit == 0)
+ stripe_unit = cct->_conf->rbd_default_stripe_unit;
+ if (opts.get(RBD_IMAGE_OPTION_STRIPE_COUNT, &stripe_count) != 0 || stripe_count == 0)
+ stripe_count = cct->_conf->rbd_default_stripe_count;
+ }
uint64_t order = 0;
- opts.get(RBD_IMAGE_OPTION_ORDER, &order);
+ if (opts.get(RBD_IMAGE_OPTION_ORDER, &order) != 0 || order == 0)
+ order = cct->_conf->rbd_default_order;
ldout(cct, 20) << "create " << &io_ctx << " name = " << imgname
<< " size = " << size << " old_format = " << old_format
return -EEXIST;
}
- if (!order)
- order = cct->_conf->rbd_default_order;
-
if (order > 25 || order < 12) {
lderr(cct) << "order must be in the range [12, 25]" << dendl;
return -EDOM;
Rados rados(io_ctx);
uint64_t bid = rados.get_instance_id();
- // if striping is enabled, use possibly custom defaults
- if (!old_format && (features & RBD_FEATURE_STRIPINGV2) &&
- !stripe_unit && !stripe_count) {
- stripe_unit = cct->_conf->rbd_default_stripe_unit;
- stripe_count = cct->_conf->rbd_default_stripe_count;
- }
-
- // normalize for default striping
- if (stripe_unit == (1ull << order) && stripe_count == 1) {
- stripe_unit = 0;
- stripe_count = 0;
- }
- if ((stripe_unit || stripe_count) &&
- (features & RBD_FEATURE_STRIPINGV2) == 0) {
+ if ((features & RBD_FEATURE_STRIPINGV2) == 0 &&
+ ((stripe_unit && stripe_unit != (1ull << order)) ||
+ (stripe_count && stripe_count != 1))) {
lderr(cct) << "STRIPINGV2 and format 2 or later required for non-default striping" << dendl;
return -EINVAL;
}
+
if ((stripe_unit && !stripe_count) ||
- (!stripe_unit && stripe_count))
+ (!stripe_unit && stripe_count)) {
+ lderr(cct) << "must specify both (or neither) of stripe-unit and stripe-count" << dendl;
return -EINVAL;
+ } else if (stripe_unit || stripe_count) {
+ if ((1ull << order) % stripe_unit || stripe_unit > (1ull << order)) {
+ lderr(cct) << "stripe unit is not a factor of the object size" << dendl;
+ return -EINVAL;
+ }
+ }
if (old_format) {
if (stripe_unit && stripe_unit != (1ull << order))
stripe_specified = true;
}
- 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 {
- if (features_specified && ((features & RBD_FEATURE_STRIPINGV2) != 0)) {
- std::cerr << "must specify both of stripe-unit and stripe-count when specify striping features" << std::endl;
- return -EINVAL;
- }
- features &= ~RBD_FEATURE_STRIPINGV2;
- }
-
if (vm.count(at::IMAGE_SHARED) && vm[at::IMAGE_SHARED].as<bool>()) {
features &= ~RBD_FEATURES_SINGLE_CLIENT;
features_specified = true;