From da47654c709aa5a2819c1ecfb918e5932525fd0f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 1 Feb 2018 13:58:15 -0600 Subject: [PATCH] osd: store ec profile with final pool We need this to reinstantiate semi-deleted ec backends. Signed-off-by: Sage Weil --- src/osd/OSD.cc | 13 ++++++++++++- src/osd/PGBackend.cc | 7 +++---- src/osd/PGBackend.h | 2 +- src/osd/PrimaryLogPG.cc | 5 +++-- src/osd/PrimaryLogPG.h | 4 +++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9f069ea7522f7..a7bb216de8f7d 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3844,10 +3844,14 @@ PG* OSD::_make_pg( { dout(10) << __func__ << " " << pgid << dendl; pg_pool_t pi; + map 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 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()); } diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc index da87d2fd66b39..a2c801dc6ad0b 100644 --- a/src/osd/PGBackend.cc +++ b/src/osd/PGBackend.cc @@ -532,26 +532,25 @@ void PGBackend::trim_rollback_object( PGBackend *PGBackend::build_pg_backend( const pg_pool_t &pool, - const OSDMapRef curmap, + const map& 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("erasure_code_dir"), - profile, + ec_profile, &ec_impl, &ss); assert(ec_impl); diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 2f9b53c377ce6..92bd20e75ba67 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -606,7 +606,7 @@ typedef ceph::shared_ptr OSDMapRef; static PGBackend *build_pg_backend( const pg_pool_t &pool, - const OSDMapRef curmap, + const map& profile, Listener *l, coll_t coll, ObjectStore::CollectionHandle &ch, diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index ba57f0d4f2a01..adda62bb47e24 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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& 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), diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index b2d3c860062db..c71472106df01 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1413,7 +1413,9 @@ protected: public: PrimaryLogPG(OSDService *o, OSDMapRef curmap, - const PGPool &_pool, spg_t p); + const PGPool &_pool, + const map& ec_profile, + spg_t p); ~PrimaryLogPG() override {} int do_command( -- 2.39.5