]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: Install stub extent cache in OSD.
authorAlex Ainscow <aainscow@uk.ibm.com>
Mon, 7 Apr 2025 08:20:44 +0000 (09:20 +0100)
committerAlex Ainscow <aainscow@uk.ibm.com>
Tue, 22 Apr 2025 07:38:15 +0000 (08:38 +0100)
The extent cache in new EC is a per OSD-shard cache will caches
reads used by read-modify-write to improve performance of sequential
IO. We want to provide a single PR with all of EC in it, so this
PR provides a non-functional stub to allow all the non-EC code to
be installed.

Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/ECExtentCache.h [new file with mode: 0644]
src/osd/ECSwitch.h
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PGBackend.cc
src/osd/PGBackend.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index 47cb7c52657a4eeb3097bc7ae097f97a56a1c2f7..63dfc99015d74c90e073e6530df231dd37b2f322 100644 (file)
@@ -128,7 +128,8 @@ ECBackend::ECBackend(
   CephContext *cct,
   ErasureCodeInterfaceRef ec_impl,
   uint64_t stripe_width,
-  ECSwitch *s)
+  ECSwitch *s,
+  ECExtentCache::LRU &ignored)
   : parent(pg), cct(cct), switcher(s),
     read_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener()),
     rmw_pipeline(cct, ec_impl, this->sinfo, get_parent()->get_eclistener(), *this),
index 715eb97c74359b28feec8868d4ab3ed303519c22..b11b946183fbc744d4f0dbe9dcb05c1a38dcdfc5 100644 (file)
@@ -433,7 +433,8 @@ public:
     CephContext *cct,
     ceph::ErasureCodeInterfaceRef ec_impl,
     uint64_t stripe_width,
-    ECSwitch *s);
+    ECSwitch *s,
+    ECExtentCache::LRU &ignored);
 
   int objects_get_attrs(
     const hobject_t &hoid,
diff --git a/src/osd/ECExtentCache.h b/src/osd/ECExtentCache.h
new file mode 100644 (file)
index 0000000..b02afec
--- /dev/null
@@ -0,0 +1,10 @@
+#pragma once
+
+// Temporary stubs
+class ECExtentCache {
+ public:
+  class LRU {
+   public:
+    LRU(uint64_t) {}
+  };
+};
index 4069662ade016333ad039a4c802925e4e220d5a2..c643b7e5cd40a5d0a44dd3d45ea7f38831050cff 100644 (file)
@@ -40,10 +40,11 @@ public:
     ObjectStore *store,
     CephContext *cct,
     ceph::ErasureCodeInterfaceRef ec_impl,
-    uint64_t stripe_width) :
+    uint64_t stripe_width,
+    ECExtentCache::LRU &lru) :
     PGBackend(cct, pg, store, coll, ch),
     legacy(pg, cct, ec_impl, stripe_width, this),
-    optimized(pg, cct, ec_impl, stripe_width, this),
+    optimized(pg, cct, ec_impl, stripe_width, this, lru),
     is_optimized_actual(get_parent()->get_pool().allows_ecoptimizations()) {}
 
   bool is_optimized() const
index 2ea6d25f442938defd97819c153ad0fe31df81da..dc68548c1595d9365b9fb10fd9fd437f8fcb0d0d 100644 (file)
@@ -5220,7 +5220,7 @@ PG* OSD::_make_pg(
   PG *pg;
   if (pi.type == pg_pool_t::TYPE_REPLICATED ||
       pi.type == pg_pool_t::TYPE_ERASURE)
-    pg = new PrimaryLogPG(&service, createmap, pool, ec_profile, pgid);
+    pg = new PrimaryLogPG(&service, createmap, pool, ec_profile, pgid, lookup_ec_extent_cache_lru(pgid));
   else
     ceph_abort();
   return pg;
@@ -5307,6 +5307,13 @@ bool OSD::try_finish_pg_delete(PG *pg, unsigned old_pg_num)
   return true;
 }
 
+ECExtentCache::LRU &OSD::lookup_ec_extent_cache_lru(spg_t pgid) const
+{
+  uint32_t shard_index = pgid.hash_to_shard(num_shards);
+  auto sdata = shards[shard_index];
+  return sdata->ec_extent_cache_lru;
+}
+
 PGRef OSD::_lookup_pg(spg_t pgid)
 {
   uint32_t shard_index = pgid.hash_to_shard(num_shards);
@@ -11066,7 +11073,9 @@ OSDShard::OSDShard(
     scheduler(ceph::osd::scheduler::make_scheduler(
       cct, osd->whoami, osd->num_shards, id, osd->store->is_rotational(),
       osd->store->get_type(), osd_op_queue, osd_op_queue_cut_off, osd->monc)),
-    context_queue(sdata_wait_lock, sdata_cond)
+    context_queue(sdata_wait_lock, sdata_cond),
+    ec_extent_cache_lru(cct->_conf.get_val<uint64_t>(
+      "ec_extent_cache_size"))
 {
   dout(0) << "using op scheduler " << *scheduler << dendl;
 }
index 1d41a44f917882acb02eaf89538fe929e91a2adf..84f70c86a405d0e0802c731d78be427a9dd0c378 100644 (file)
@@ -1021,6 +1021,11 @@ struct OSDShard {
 
   ContextQueue context_queue;
 
+  //This is an extent cache for the erasure coding. Specifically, this acts as
+  //a least-recently-used cache invalidator, allowing for cache shards to last
+  //longer than the most recent IO in each object.
+  ECExtentCache::LRU ec_extent_cache_lru;
+
   void _attach_pg(OSDShardPGSlot *slot, PG *pg);
   void _detach_pg(OSDShardPGSlot *slot);
 
@@ -1206,6 +1211,12 @@ public:
    */
   static CompatSet get_osd_compat_set();
 
+  /**
+   * lookup_ec_extent_cache_lru()
+   * @param pgid -
+   * @return extent cache for LRU
+   */
+  ECExtentCache::LRU &lookup_ec_extent_cache_lru(spg_t pgid) const;
 
 private:
   class C_Tick;
index 19ac1ab70ea66e16cdede28ca0ed0f6e9feaf6d7..f7eeb225e61b7e98345db803e18daedabf7aa1e7 100644 (file)
@@ -739,7 +739,8 @@ PGBackend *PGBackend::build_pg_backend(
   coll_t coll,
   ObjectStore::CollectionHandle &ch,
   ObjectStore *store,
-  CephContext *cct)
+  CephContext *cct,
+  ECExtentCache::LRU &ec_extent_cache_lru)
 {
   ErasureCodeProfile ec_profile = profile;
   switch (pool.type) {
@@ -763,7 +764,8 @@ PGBackend *PGBackend::build_pg_backend(
       store,
       cct,
       ec_impl,
-      pool.stripe_width);
+      pool.stripe_width,
+      ec_extent_cache_lru);
   }
   default:
     ceph_abort();
index c809469ae50dc0670fb402f00833194c413873fb..a69a7df0c22a8490b4a976602e4aae873f8eba03 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "ECListener.h"
 #include "ECTypes.h"
+#include "ECExtentCache.h"
 #include "osd_types.h"
 #include "pg_features.h"
 #include "common/intrusive_timer.h"
@@ -618,7 +619,8 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
      coll_t coll,
      ObjectStore::CollectionHandle &ch,
      ObjectStore *store,
-     CephContext *cct);
+     CephContext *cct,
+     ECExtentCache::LRU &ec_extent_cache_lru);
 };
 
 #endif
index 1340ec88679a7f6379fcc3588dbe480c2a3d5d09..3dfc03029942533ea5e4c91ac510396ced97a5f9 100644 (file)
@@ -1772,11 +1772,12 @@ void PrimaryLogPG::release_object_locks(
 
 PrimaryLogPG::PrimaryLogPG(OSDService *o, OSDMapRef curmap,
                           const PGPool &_pool,
-                          const map<string,string>& ec_profile, spg_t p) :
+                          const map<string,string>& ec_profile, spg_t p,
+                          ECExtentCache::LRU &ec_extent_cache_lru) :
   PG(o, curmap, _pool, p),
   pgbackend(
     PGBackend::build_pg_backend(
-      _pool.info, ec_profile, this, coll_t(p), ch, o->store, cct)),
+      _pool.info, ec_profile, this, coll_t(p), ch, o->store, cct, ec_extent_cache_lru)),
   object_contexts(o->cct, o->cct->_conf->osd_pg_object_context_cache_count),
   new_backfill(false),
   temp_seq(0),
index b365cf29457016405f72d60f30de83ce5361e955..c1c92e0353a7ead5e520ec50c61a55152508495b 100644 (file)
@@ -1528,7 +1528,8 @@ public:
   PrimaryLogPG(OSDService *o, OSDMapRef curmap,
               const PGPool &_pool,
               const std::map<std::string,std::string>& ec_profile,
-              spg_t p);
+              spg_t p,
+               ECExtentCache::LRU &ec_extent_cache_lru);
   ~PrimaryLogPG() override;
 
   void do_command(