From 19f8db9692726bc31ea13fd78ba46bec2e005bb8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 16 Mar 2017 17:43:19 +0800 Subject: [PATCH] mon/OSDMonitor: mapping is not optional anymore as pg_creatings needs mapping to get the acting_primary osd of the creating pg, so we can send the pg-create message to it if it subscribes to this information, mapping should always be available now. Signed-off-by: Kefu Chai --- src/mon/OSDMonitor.cc | 31 ++++++++++++++----------------- src/mon/OSDMonitor.h | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4579047ce01dc..5691c3de8a451 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -380,15 +380,12 @@ void OSDMonitor::on_active() << dendl; mapping_job->abort(); } - if (g_conf->mon_osd_prime_pg_temp) { - C_PrintTime *fin = new C_PrintTime(osdmap.get_epoch()); - mapping.reset(new OSDMapMapping); - mapping_job = mapping->start_update(osdmap, mapper, - g_conf->mon_osd_mapping_pgs_per_chunk); - dout(10) << __func__ << " started mapping job " << mapping_job.get() - << " at " << fin->start << dendl; - mapping_job->set_finish_event(fin); - } + C_PrintTime *fin = new C_PrintTime(osdmap.get_epoch()); + mapping_job = mapping.start_update(osdmap, mapper, + g_conf->mon_osd_mapping_pgs_per_chunk); + dout(10) << __func__ << " started mapping job " << mapping_job.get() + << " at " << fin->start << dendl; + mapping_job->set_finish_event(fin); } void OSDMonitor::on_shutdown() @@ -1047,13 +1044,13 @@ void OSDMonitor::maybe_prime_pg_temp() if (!all) { unsigned estimate = - mapping->get_osd_acting_pgs(*osds.begin()).size() * osds.size(); - if (estimate > mapping->get_num_pgs() * + mapping.get_osd_acting_pgs(*osds.begin()).size() * osds.size(); + if (estimate > mapping.get_num_pgs() * g_conf->mon_osd_prime_pg_temp_max_estimate) { dout(10) << __func__ << " estimate " << estimate << " pgs on " << osds.size() << " osds >= " << g_conf->mon_osd_prime_pg_temp_max_estimate << " of total " - << mapping->get_num_pgs() << " pgs, all" + << mapping.get_num_pgs() << " pgs, all" << dendl; all = true; } else { @@ -1085,7 +1082,7 @@ void OSDMonitor::maybe_prime_pg_temp() int n = chunk; std::unordered_set did_pgs; for (auto osd : osds) { - auto& pgs = mapping->get_osd_acting_pgs(osd); + auto& pgs = mapping.get_osd_acting_pgs(osd); dout(20) << __func__ << " osd." << osd << " " << pgs << dendl; for (auto pgid : pgs) { if (!did_pgs.insert(pgid).second) { @@ -1117,7 +1114,7 @@ void OSDMonitor::prime_pg_temp( } vector up, acting; - mapping->get(pgid, &up, nullptr, &acting, nullptr); + mapping.get(pgid, &up, nullptr, &acting, nullptr); vector next_up, next_acting; int next_up_primary, next_acting_primary; @@ -1158,16 +1155,16 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) int r = pending_inc.propagate_snaps_to_tiers(g_ceph_context, osdmap); assert(r == 0); - if (mapping && mapping_job) { + if (mapping_job) { if (!mapping_job->is_done()) { dout(1) << __func__ << " skipping prime_pg_temp; mapping job " << mapping_job.get() << " did not complete, " << mapping_job->shards << " left" << dendl; mapping_job->abort(); - } else if (mapping->get_epoch() == osdmap.get_epoch()) { + } else if (mapping.get_epoch() == osdmap.get_epoch()) { dout(1) << __func__ << " skipping prime_pg_temp; mapping job " << mapping_job.get() << " is prior epoch " - << mapping->get_epoch() << dendl; + << mapping.get_epoch() << dendl; } else { if (g_conf->mon_osd_prime_pg_temp) { maybe_prime_pg_temp(); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 8a029d9c90e73..bd357fa225900 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -114,7 +114,7 @@ class OSDMonitor : public PaxosService { CephContext *cct; ParallelPGMapper mapper; ///< for background pg work - unique_ptr mapping; ///< pg <-> osd mappings + OSDMapMapping mapping; ///< pg <-> osd mappings unique_ptr mapping_job; ///< background mapping job public: -- 2.39.5