if (cct->_conf.get_val<bool>("osd_pool_default_flag_ec_optimizations")) {
// This will fail if the pool cannot support ec optimizations.
- enable_pool_ec_optimizations(*pi, nullptr, true);
+ enable_pool_ec_optimizations(*pi, nullptr, true, false);
}
pending_inc.new_pool_names[pool] = name;
}
int OSDMonitor::enable_pool_ec_optimizations(pg_pool_t &p,
- stringstream *ss, bool enable) {
+ stringstream *ss, bool enable, bool force) {
if (!p.is_erasure()) {
if (ss) {
*ss << "allow_ec_optimizations can only be enabled for an erasure coded pool";
}
if (enable) {
ErasureCodeInterfaceRef erasure_code;
- unsigned int k, m;
+ unsigned int k, m, chunk_size;
stringstream tmp;
int err = get_erasure_code(p.erasure_code_profile, &erasure_code, &tmp);
if (err == 0) {
k = erasure_code->get_data_chunk_count();
m = erasure_code->get_coding_chunk_count();
+ chunk_size = erasure_code->get_chunk_size(p.get_stripe_width());
} else {
if (ss) {
*ss << "get_erasure_code failed: " << tmp.str();
return -EINVAL;
}
if ((erasure_code->get_supported_optimizations() &
- ErasureCodeInterface::FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED) == 0) {
+ ErasureCodeInterface::FLAG_EC_PLUGIN_OPTIMIZED_SUPPORTED) == 0 ||
+ ((chunk_size % 4096) != 0 && !force)) {
if (ss) {
*ss << "ec optimizations not currently supported for pool profile.";
}
}
}
p.flags |= pg_pool_t::FLAG_EC_OPTIMIZATIONS;
- } else {
+ } else if (!force) {
if ((p.flags & pg_pool_t::FLAG_EC_OPTIMIZATIONS) != 0) {
if (ss) {
*ss << "allow_ec_optimizations cannot be disabled once enabled";
}
return -EINVAL;
}
+ } else {
+ // Do not undo the non-primary shards change. User should be instructed
+ // to delete the pool (and migrate data off).
+ p.flags &= ~pg_pool_t::FLAG_EC_OPTIMIZATIONS;
}
return 0;
}
return -EINVAL;
}
bool was_enabled = p.allows_ecoptimizations();
- int r = enable_pool_ec_optimizations(p, nullptr, enable);
+ bool force = false;
+ cmd_getval(cmdmap, "yes_i_really_mean_it", force);
+ int r = enable_pool_ec_optimizations(p, nullptr, enable, force);
if (r != 0) {
return r;
}