From: Kefu Chai Date: Sun, 19 Mar 2017 06:02:15 +0000 (+0800) Subject: mon/OSDMonitor: run mapping on peons also X-Git-Tag: v12.0.2~256^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=11f82480a0e9f6c498c230441051e01fb359f27a;p=ceph.git mon/OSDMonitor: run mapping on peons also otherwise subcriptions on peons won't get the creating_pgs notification mapping updated. we want to send the notification from peons also. and the notifications should be updated with the updated pg mapping. Signed-off-by: Kefu Chai --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 5691c3de8a45..d5a48db1ec4e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -98,10 +98,10 @@ OSDMonitor::OSDMonitor( const string& service_name) : PaxosService(mn, p, service_name), cct(cct), - mapper(mn->cct, &mn->cpu_tp), inc_osd_cache(g_conf->mon_osd_cache_size), full_osd_cache(g_conf->mon_osd_cache_size), last_attempted_minwait_time(utime_t()), + mapper(mn->cct, &mn->cpu_tp), op_tracker(cct, true, 1) {} @@ -335,6 +335,27 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) // make sure our feature bits reflect the latest map update_msgr_features(); + + if (!mon->is_leader()) { + // will be called by on_active() on the leader, avoid doing so twice + start_mapping(); + } +} + +void OSDMonitor::start_mapping() +{ + // initiate mapping job + if (mapping_job) { + dout(10) << __func__ << " canceling previous mapping_job " << mapping_job.get() + << dendl; + mapping_job->abort(); + } + auto *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::update_msgr_features() @@ -360,10 +381,9 @@ void OSDMonitor::on_active() { update_logger(); - if (mon->is_leader()) + if (mon->is_leader()) { mon->clog->info() << "osdmap " << osdmap; - - if (!mon->is_leader()) { + } else { list ls; take_all_failures(ls); while (!ls.empty()) { @@ -373,19 +393,7 @@ void OSDMonitor::on_active() ls.pop_front(); } } - - // initiate mapping job - if (mapping_job) { - dout(10) << __func__ << " canceling previous mapping_job " << mapping_job.get() - << dendl; - mapping_job->abort(); - } - 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); + start_mapping(); } void OSDMonitor::on_shutdown() diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index bd357fa22590..01428ef457b0 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -113,10 +113,6 @@ struct failure_info_t { class OSDMonitor : public PaxosService { CephContext *cct; - ParallelPGMapper mapper; ///< for background pg work - OSDMapMapping mapping; ///< pg <-> osd mappings - unique_ptr mapping_job; ///< background mapping job - public: OSDMap osdmap; @@ -210,6 +206,11 @@ private: void maybe_prime_pg_temp(); void prime_pg_temp(const OSDMap& next, pg_t pgid); + ParallelPGMapper mapper; ///< for background pg work + OSDMapMapping mapping; ///< pg <-> osd mappings + unique_ptr mapping_job; ///< background mapping job + void start_mapping(); + void update_logger(); void handle_query(PaxosServiceMessage *m);