]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: Add function to enable EC direct reads.
authorAlex Ainscow <aainscow@uk.ibm.com>
Thu, 5 Feb 2026 13:25:20 +0000 (13:25 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Fri, 6 Feb 2026 10:31:30 +0000 (10:31 +0000)
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/mon/OSDMonitor.cc

index e297974d8239b80b719067805928ba8282b996fc..d39bb2f4d8cf1cad0652f81f3e716da25b063204 100644 (file)
@@ -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));
   }
 }