@@ -29,7 +29,7 @@ class ECSwitch : public PGBackend
2929 friend class ECReadPred ;
3030
3131 ECLegacy::ECBackendL legacy;
32- ECLegacy::ECBackendL optimized;
32+ ECBackend optimized;
3333 bool is_optimized_actual;
3434
3535public:
@@ -44,12 +44,13 @@ class ECSwitch : public PGBackend
4444 PGBackend (cct, pg, store, coll, ch),
4545 legacy (pg, cct, ec_impl, stripe_width, this ),
4646 optimized (pg, cct, ec_impl, stripe_width, this ),
47- is_optimized_actual (false ) {}
47+ is_optimized_actual (get_parent()-> get_pool ().allows_ecoptimizations() ) {}
4848
4949 bool is_optimized () const
5050 {
51- // FIXME: Interface not yet implemented.
52- // ceph_assert(is_optimized_actual == get_parent()->get_pool().allows_ecoptimizations());
51+ // FIXME: Once we trust this, we can remove this assert, as it adds
52+ // function call overhead.
53+ ceph_assert (is_optimized_actual == get_parent ()->get_pool ().allows_ecoptimizations ());
5354 return is_optimized_actual;
5455 }
5556
@@ -84,7 +85,7 @@ class ECSwitch : public PGBackend
8485 private:
8586 const ECSwitch *switcher;
8687 std::unique_ptr<ECLegacy::ECBackendL::ECRecPred> legacy;
87- std::unique_ptr<ECLegacy::ECBackendL ::ECRecPred> optimized;
88+ std::unique_ptr<ECBackend ::ECRecPred> optimized;
8889 };
8990
9091 class ECReadPred : public IsPGReadablePredicate
@@ -111,7 +112,7 @@ class ECSwitch : public PGBackend
111112 private:
112113 const ECSwitch *switcher;
113114 std::unique_ptr<ECLegacy::ECBackendL::ECReadPred> legacy;
114- std::unique_ptr<ECLegacy::ECBackendL ::ECReadPred> optimized;
115+ std::unique_ptr<ECBackend ::ECReadPred> optimized;
115116 };
116117
117118 RecoveryHandle *open_recovery_op () override
@@ -181,7 +182,11 @@ class ECSwitch : public PGBackend
181182 else {
182183 legacy.on_change ();
183184 }
184- // FIXME: Switch to new EC here.
185+
186+ if (!is_optimized_actual)
187+ is_optimized_actual = get_parent ()->get_pool ().allows_ecoptimizations ();
188+ else
189+ ceph_assert (get_parent ()->get_pool ().allows_ecoptimizations ());
185190 }
186191
187192 void clear_recovery_state () override
@@ -345,7 +350,7 @@ class ECSwitch : public PGBackend
345350 object_size_to_shard_size (const uint64_t size, int shard) const override
346351 {
347352 if (is_optimized ()) {
348- return optimized.object_size_to_shard_size (size);
353+ return optimized.object_size_to_shard_size (size, shard );
349354 }
350355 return legacy.object_size_to_shard_size (size);
351356 // All shards are the same size.
0 commit comments