]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: store ec profile with final pool
authorSage Weil <sage@redhat.com>
Thu, 1 Feb 2018 19:58:15 +0000 (13:58 -0600)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:26:51 +0000 (08:26 -0500)
We need this to reinstantiate semi-deleted ec backends.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/PGBackend.cc
src/osd/PGBackend.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index 9f069ea7522f758cbf590175ee98f08069d857ee..a7bb216de8f7d31c631401be32d75ab460703eae 100644 (file)
@@ -3844,10 +3844,14 @@ PG* OSD::_make_pg(
 {
   dout(10) << __func__ << " " << pgid << dendl;
   pg_pool_t pi;
+  map<string,string> ec_profile;
   string name;
   if (createmap->have_pg_pool(pgid.pool())) {
     pi = *createmap->get_pg_pool(pgid.pool());
     name = createmap->get_pool_name(pgid.pool());
+    if (pi.is_erasure()) {
+      ec_profile = createmap->get_erasure_code_profile(pi.erasure_code_profile);
+    }
   } else {
     // pool was deleted; grab final pg_pool_t off disk.
     ghobject_t oid = make_final_pool_info_oid(pgid.pool());
@@ -3857,12 +3861,13 @@ PG* OSD::_make_pg(
     auto p = bl.begin();
     decode(pi, p);
     decode(name, p);
+    decode(ec_profile, p);
   }
   PGPool pool(cct, createmap, pgid.pool(), pi, name);
   PG *pg;
   if (pi.type == pg_pool_t::TYPE_REPLICATED ||
       pi.type == pg_pool_t::TYPE_ERASURE)
-    pg = new PrimaryLogPG(&service, createmap, pool, pgid);
+    pg = new PrimaryLogPG(&service, createmap, pool, ec_profile, pgid);
   else
     ceph_abort();
   return pg;
@@ -7509,6 +7514,12 @@ void OSD::handle_osd_map(MOSDMap *m)
        encode(j.second, bl, CEPH_FEATURES_ALL);
        string name = lastmap->get_pool_name(j.first);
        encode(name, bl);
+       map<string,string> profile;
+       if (lastmap->get_pg_pool(j.first)->is_erasure()) {
+         profile = lastmap->get_erasure_code_profile(
+           lastmap->get_pg_pool(j.first)->erasure_code_profile);
+       }
+       encode(profile, bl);
        t.write(coll_t::meta(), obj, 0, bl.length(), bl);
        service.store_deleted_pool_pg_num(j.first, j.second.get_pg_num());
       }
index da87d2fd66b39016db59a6d1264c47c1f9b908a9..a2c801dc6ad0beac6cabe35a32eb6246c559b2f5 100644 (file)
@@ -532,26 +532,25 @@ void PGBackend::trim_rollback_object(
 
 PGBackend *PGBackend::build_pg_backend(
   const pg_pool_t &pool,
-  const OSDMapRef curmap,
+  const map<string,string>& profile,
   Listener *l,
   coll_t coll,
   ObjectStore::CollectionHandle &ch,
   ObjectStore *store,
   CephContext *cct)
 {
+  ErasureCodeProfile ec_profile = profile;
   switch (pool.type) {
   case pg_pool_t::TYPE_REPLICATED: {
     return new ReplicatedBackend(l, coll, ch, store, cct);
   }
   case pg_pool_t::TYPE_ERASURE: {
     ErasureCodeInterfaceRef ec_impl;
-    ErasureCodeProfile profile = curmap->get_erasure_code_profile(pool.erasure_code_profile);
-    assert(profile.count("plugin"));
     stringstream ss;
     ceph::ErasureCodePluginRegistry::instance().factory(
       profile.find("plugin")->second,
       cct->_conf->get_val<std::string>("erasure_code_dir"),
-      profile,
+      ec_profile,
       &ec_impl,
       &ss);
     assert(ec_impl);
index 2f9b53c377ce65259c82c31a17729aad97f3119b..92bd20e75ba67a9a259013de499ab47d80874a85 100644 (file)
@@ -606,7 +606,7 @@ typedef ceph::shared_ptr<const OSDMap> OSDMapRef;
 
    static PGBackend *build_pg_backend(
      const pg_pool_t &pool,
-     const OSDMapRef curmap,
+     const map<string,string>& profile,
      Listener *l,
      coll_t coll,
      ObjectStore::CollectionHandle &ch,
index ba57f0d4f2a01b39197c86aca5122b611d3cd3a8..adda62bb47e241fd6152dec32858275a6b54eadd 100644 (file)
@@ -1653,11 +1653,12 @@ void PrimaryLogPG::calc_trim_to()
 }
 
 PrimaryLogPG::PrimaryLogPG(OSDService *o, OSDMapRef curmap,
-                          const PGPool &_pool, spg_t p) :
+                          const PGPool &_pool,
+                          const map<string,string>& ec_profile, spg_t p) :
   PG(o, curmap, _pool, p),
   pgbackend(
     PGBackend::build_pg_backend(
-      _pool.info, curmap, this, coll_t(p), ch, o->store, cct)),
+      _pool.info, ec_profile, this, coll_t(p), ch, o->store, cct)),
   object_contexts(o->cct, o->cct->_conf->osd_pg_object_context_cache_count),
   snapset_contexts_lock("PrimaryLogPG::snapset_contexts_lock"),
   new_backfill(false),
index b2d3c860062db8b0136973689c25a3b9baa510a3..c71472106df012924de5c5cbf2640c45dafd46e4 100644 (file)
@@ -1413,7 +1413,9 @@ protected:
 
 public:
   PrimaryLogPG(OSDService *o, OSDMapRef curmap,
-              const PGPool &_pool, spg_t p);
+              const PGPool &_pool,
+              const map<string,string>& ec_profile,
+              spg_t p);
   ~PrimaryLogPG() override {}
 
   int do_command(