@@ -5410,7 +5410,8 @@ namespace {
54105410 CSUM_TYPE, CSUM_MAX_BLOCK, CSUM_MIN_BLOCK, FINGERPRINT_ALGORITHM,
54115411 PG_AUTOSCALE_MODE, PG_NUM_MIN, TARGET_SIZE_BYTES, TARGET_SIZE_RATIO,
54125412 PG_AUTOSCALE_BIAS, DEDUP_TIER, DEDUP_CHUNK_ALGORITHM,
5413- DEDUP_CDC_CHUNK_SIZE, POOL_EIO, BULK, PG_NUM_MAX, READ_RATIO };
5413+ DEDUP_CDC_CHUNK_SIZE, POOL_EIO, BULK, PG_NUM_MAX, READ_RATIO,
5414+ EC_OPTIMIZATIONS };
54145415
54155416 std::set<osd_pool_get_choices>
54165417 subtract_second_from_first (const std::set<osd_pool_get_choices>& first,
@@ -6215,7 +6216,8 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
62156216 {" dedup_chunk_algorithm" , DEDUP_CHUNK_ALGORITHM},
62166217 {" dedup_cdc_chunk_size" , DEDUP_CDC_CHUNK_SIZE},
62176218 {" bulk" , BULK},
6218- {" read_ratio" , READ_RATIO}
6219+ {" read_ratio" , READ_RATIO},
6220+ {" allow_ec_optimizations" , EC_OPTIMIZATIONS}
62196221 };
62206222
62216223 typedef std::set<osd_pool_get_choices> choices_set_t ;
@@ -6230,7 +6232,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
62306232 HIT_SET_GRADE_DECAY_RATE, HIT_SET_SEARCH_LAST_N
62316233 };
62326234 const choices_set_t ONLY_ERASURE_CHOICES = {
6233- EC_OVERWRITES, ERASURE_CODE_PROFILE
6235+ EC_OVERWRITES, ERASURE_CODE_PROFILE, EC_OPTIMIZATIONS
62346236 };
62356237 const choices_set_t ONLY_REPLICA_CHOICES = {
62366238 READ_RATIO
@@ -6462,17 +6464,23 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
64626464 case DEDUP_CHUNK_ALGORITHM:
64636465 case DEDUP_CDC_CHUNK_SIZE:
64646466 case READ_RATIO:
6465- pool_opts_t ::key_t key = pool_opts_t::get_opt_desc (i->first ).key ;
6466- if (p->opts .is_set (key)) {
6467- if (*it == CSUM_TYPE) {
6468- int64_t val;
6469- p->opts .get (pool_opts_t ::CSUM_TYPE, &val);
6470- f->dump_string (i->first .c_str (), Checksummer::get_csum_type_string (val));
6471- } else {
6472- p->opts .dump (i->first , f.get ());
6473- }
6467+ {
6468+ pool_opts_t ::key_t key = pool_opts_t::get_opt_desc (i->first ).key ;
6469+ if (p->opts .is_set (key)) {
6470+ if (*it == CSUM_TYPE) {
6471+ int64_t val;
6472+ p->opts .get (pool_opts_t ::CSUM_TYPE, &val);
6473+ f->dump_string (i->first .c_str (), Checksummer::get_csum_type_string (val));
6474+ } else {
6475+ p->opts .dump (i->first , f.get ());
6476+ }
6477+ }
64746478 }
64756479 break ;
6480+ case EC_OPTIMIZATIONS:
6481+ f->dump_bool (" allow_ec_optimizations" ,
6482+ p->has_flag (pg_pool_t ::FLAG_EC_OPTIMIZATIONS));
6483+ break ;
64766484 }
64776485 }
64786486 f->close_section ();
@@ -6644,6 +6652,11 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
66446652 }
66456653 }
66466654 break ;
6655+ case EC_OPTIMIZATIONS:
6656+ ss << " allow_ec_optimizations: " <<
6657+ (p->has_flag (pg_pool_t ::FLAG_EC_OPTIMIZATIONS) ? " true" : " false" ) <<
6658+ " \n " ;
6659+ break ;
66476660 }
66486661 rdata.append (ss.str ());
66496662 ss.str (" " );
@@ -8796,8 +8809,31 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
87968809 if (val == " true" || (interr.empty () && n == 1 )) {
87978810 p.flags |= pg_pool_t ::FLAG_EC_OVERWRITES;
87988811 } else if (val == " false" || (interr.empty () && n == 0 )) {
8799- ss << " ec overwrites cannot be disabled once enabled" ;
8812+ if ((p.flags & pg_pool_t ::FLAG_EC_OVERWRITES) != 0 ) {
8813+ ss << " ec overwrites cannot be disabled once enabled" ;
8814+ return -EINVAL;
8815+ }
8816+ } else {
8817+ ss << " expecting value 'true', 'false', '0', or '1'" ;
88008818 return -EINVAL;
8819+ }
8820+ } else if (var == " allow_ec_optimizations" ) {
8821+ if (!p.is_erasure ()) {
8822+ ss << " allow_ec_optimizations can only be enabled for an erasure coded pool" ;
8823+ return -EINVAL;
8824+ }
8825+ if (osdmap.require_osd_release < ceph_release_t ::tentacle) {
8826+ ss << " All OSDs must be upgraded to tentacle or "
8827+ << " later before setting allow_ec_optimizations" ;
8828+ return -EINVAL;
8829+ }
8830+ if (val == " true" || (interr.empty () && n == 1 )) {
8831+ p.flags |= pg_pool_t ::FLAG_EC_OPTIMIZATIONS;
8832+ } else if (val == " false" || (interr.empty () && n == 0 )) {
8833+ if ((p.flags & pg_pool_t ::FLAG_EC_OPTIMIZATIONS) != 0 ) {
8834+ ss << " allow_ec_optimizations cannot be disabled once enabled" ;
8835+ return -EINVAL;
8836+ }
88018837 } else {
88028838 ss << " expecting value 'true', 'false', '0', or '1'" ;
88038839 return -EINVAL;
0 commit comments