]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: EC Switcher actually switches between two (identical) EC implementations
authorAlex Ainscow <aainscow@uk.ibm.com>
Tue, 11 Mar 2025 11:00:59 +0000 (11:00 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Wed, 2 Apr 2025 22:34:08 +0000 (23:34 +0100)
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/osd/ECSwitch.h

index 9d56a6c138b8133a7537b66e75c73b4d1da75a75..893869793ef12f8e5cc80095e6672f4754ac5387 100644 (file)
@@ -29,7 +29,7 @@ class ECSwitch : public PGBackend
   friend class ECReadPred;
 
   ECLegacy::ECBackendL legacy;
-  ECLegacy::ECBackendL optimized;
+  ECBackend optimized;
   bool is_optimized_actual;
 
 public:
@@ -44,12 +44,13 @@ public:
     PGBackend(cct, pg, store, coll, ch),
     legacy(pg, cct, ec_impl, stripe_width, this),
     optimized(pg, cct, ec_impl, stripe_width, this),
-    is_optimized_actual(false) {}
+    is_optimized_actual(get_parent()->get_pool().allows_ecoptimizations()) {}
 
   bool is_optimized() const
   {
-    // FIXME: Interface not yet implemented.
-    //ceph_assert(is_optimized_actual == get_parent()->get_pool().allows_ecoptimizations());
+    // FIXME: Once we trust this, we can remove this assert, as it adds
+    //        function call overhead.
+    ceph_assert(is_optimized_actual == get_parent()->get_pool().allows_ecoptimizations());
     return is_optimized_actual;
   }
 
@@ -84,7 +85,7 @@ public:
   private:
     const ECSwitch *switcher;
     std::unique_ptr<ECLegacy::ECBackendL::ECRecPred> legacy;
-    std::unique_ptr<ECLegacy::ECBackendL::ECRecPred> optimized;
+    std::unique_ptr<ECBackend::ECRecPred> optimized;
   };
 
   class ECReadPred : public IsPGReadablePredicate
@@ -111,7 +112,7 @@ public:
   private:
     const ECSwitch *switcher;
     std::unique_ptr<ECLegacy::ECBackendL::ECReadPred> legacy;
-    std::unique_ptr<ECLegacy::ECBackendL::ECReadPred> optimized;
+    std::unique_ptr<ECBackend::ECReadPred> optimized;
   };
 
   RecoveryHandle *open_recovery_op() override
@@ -181,7 +182,11 @@ public:
     else {
       legacy.on_change();
     }
-    //FIXME: Switch to new EC here.
+
+    if (!is_optimized_actual)
+      is_optimized_actual = get_parent()->get_pool().allows_ecoptimizations();
+    else
+      ceph_assert(get_parent()->get_pool().allows_ecoptimizations());
   }
 
   void clear_recovery_state() override
@@ -345,7 +350,7 @@ public:
   object_size_to_shard_size(const uint64_t size, int shard) const override
   {
     if (is_optimized()) {
-      return optimized.object_size_to_shard_size(size);
+      return optimized.object_size_to_shard_size(size, shard);
     }
     return legacy.object_size_to_shard_size(size);
     // All shards are the same size.