]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: run mapping on peons also
authorKefu Chai <kchai@redhat.com>
Sun, 19 Mar 2017 06:02:15 +0000 (14:02 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 30 Mar 2017 12:21:17 +0000 (20:21 +0800)
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 <kchai@redhat.com>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 5691c3de8a451b93a156f5d4b558b136222aeeba..d5a48db1ec4ef985127e720d6d84bda6b5401148 100644 (file)
@@ -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<MonOpRequestRef> 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()
index bd357fa22590093b21fb3169cd9e031462f02faa..01428ef457b00319129c1c65e3000464cc6a4977 100644 (file)
@@ -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<ParallelPGMapper::Job> 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<ParallelPGMapper::Job> mapping_job;  ///< background mapping job
+  void start_mapping();
+
   void update_logger();
 
   void handle_query(PaxosServiceMessage *m);