From: Alex Ainscow Date: Thu, 5 Feb 2026 13:25:20 +0000 (+0000) Subject: mon: Add function to enable EC direct reads. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6d2d1faccfcb6beced5e783855d7908275a62206;p=ceph-ci.git mon: Add function to enable EC direct reads. Signed-off-by: Alex Ainscow --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e297974d823..d39bb2f4d8c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -8455,25 +8455,42 @@ int OSDMonitor::enable_pool_ec_optimizations(pg_pool_t &p, } void OSDMonitor::enable_pool_ec_direct_reads(pg_pool_t &p) { - if (p.is_erasure()) { - ErasureCodeInterfaceRef erasure_code; - stringstream tmp; - int err = get_erasure_code(p.erasure_code_profile, &erasure_code, &tmp); + if (!p.is_erasure()) { + return; + } + ErasureCodeInterfaceRef erasure_code; + stringstream tmp; + int err = get_erasure_code(p.erasure_code_profile, &erasure_code, &tmp); + + // Once this feature is finished, we will replace this with upgrade code. + // The upgrade code will enable the split read flag once all OSDs are at + // Umbrella. For now, if the plugin does not support direct reads, we just + // disable it. All plugins and techniques should be capable of supporting + // direct reads, but we put in place this capability to reduce the test + // matrix for less important plugins/techniques. + // + // To enable direct reads in development, set the osd_pool_default_flags to + // 1<<20 = 0x100000 = 1048576 + if (err != 0 || !p.allows_ecoptimizations() || + (erasure_code->get_supported_optimizations() & + ErasureCodeInterface::FLAG_EC_PLUGIN_DIRECT_READS) == 0) { + p.flags &= ~pg_pool_t::FLAG_CLIENT_SPLIT_READS; + return; + } - // Once this feature is finished, we will replace this with upgrade code. - // The upgrade code will enable the split read flag once all OSDs are at - // Umbrella. For now, if the plugin does not support direct reads, we just - // disable it. All plugins and techniques should be capable of supporting - // direct reads, but we put in place this capability to reduce the test - // matrix for less important plugins/techniques. - // - // To enable direct reads in development, set the osd_pool_default_flags to - // 1<<20 = 0x100000 = 1048576 - if (err != 0 || !p.allows_ecoptimizations() || - (erasure_code->get_supported_optimizations() & - ErasureCodeInterface::FLAG_EC_PLUGIN_DIRECT_READS) == 0) { - p.flags &= ~pg_pool_t::FLAG_CLIENT_SPLIT_READS; + auto mapping = erasure_code->get_chunk_mapping(); + + // Plugins are permitted to provide an incomplete mapping, which makes for + // an inconvenient interface. Here make it either fully populated or not + // populated at all. + if (mapping.size() > 0) { + int shard_count = erasure_code->get_chunk_count(); + int old_count = mapping.size(); + mapping.resize(shard_count); + for (int s = old_count; s < shard_count; ++s) { + mapping[s] = shard_id_t(s); } + p.set_shard_mapping(std::move(mapping)); } }