]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: send updated monmap to its subscribers 11743/head
authorKefu Chai <kchai@redhat.com>
Thu, 13 Oct 2016 05:19:27 +0000 (13:19 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 2 Nov 2016 08:03:28 +0000 (16:03 +0800)
prior to this change, we sends monmap when serving the subscription
requests, but the updates are not sent to the subscribers anymore.
so we need to send latest monmap to subscribes and update the
subscription status accordingly when the monmap is updated.

http://tracker.ceph.com/issues/17558
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit c2b348b12c47ba505f72228ae0ea9b1a1b674719)
Conflicts:
Monitor.cc: trivial resolution

src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc
src/mon/MonmapMonitor.h

index 404735149809e6f123f3c7e87fd426940168a4b4..3c8bb3e4b3d73cd2686aa7c6f1e425781fafe0f1 100644 (file)
@@ -4292,7 +4292,7 @@ void Monitor::handle_subscribe(MonOpRequestRef op)
        pgmon()->check_sub(s->sub_map["osd_pg_creates"]);
       }
     } else if (p->first == "monmap") {
-      check_sub(s->sub_map["monmap"]);
+      monmon()->check_sub(s->sub_map[p->first]);
     } else if (logmon()->sub_name_to_id(p->first) >= 0) {
       logmon()->check_sub(s->sub_map[p->first]);
     }
@@ -4381,32 +4381,6 @@ bool Monitor::ms_handle_reset(Connection *con)
   return true;
 }
 
-void Monitor::check_subs()
-{
-  string type = "monmap";
-  if (session_map.subs.count(type) == 0)
-    return;
-  xlist<Subscription*>::iterator p = session_map.subs[type]->begin();
-  while (!p.end()) {
-    Subscription *sub = *p;
-    ++p;
-    check_sub(sub);
-  }
-}
-
-void Monitor::check_sub(Subscription *sub)
-{
-  dout(10) << "check_sub monmap next " << sub->next << " have " << monmap->get_epoch() << dendl;
-  if (sub->next <= monmap->get_epoch()) {
-    send_latest_monmap(sub->session->con.get());
-    if (sub->onetime)
-      session_map.remove_sub(sub);
-    else
-      sub->next = monmap->get_epoch() + 1;
-  }
-}
-
-
 // -----
 
 void Monitor::send_latest_monmap(Connection *con)
index bf94dea83a9593e648d8739c6461563ef6e1463f..cc49a3bca38731407c3b1ed99088bb75a33f6988 100644 (file)
@@ -690,9 +690,6 @@ public:
   MonSessionMap session_map;
   AdminSocketHook *admin_hook;
 
-  void check_subs();
-  void check_sub(Subscription *sub);
-
   void send_latest_monmap(Connection *con);
 
   // messages
index 1ff6e06b88bddcaff4193147449b96e103903c58..a38f3fe956919c45a141021dc37c03464bea64b3 100644 (file)
@@ -76,6 +76,8 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap)
     t->erase("mkfs", "monmap");
     mon->store->apply_transaction(t);
   }
+
+  check_subs();
 }
 
 void MonmapMonitor::create_pending()
@@ -580,3 +582,29 @@ int MonmapMonitor::get_monmap(bufferlist &bl)
   }
   return 0;
 }
+
+void MonmapMonitor::check_subs()
+{
+  const string type = "monmap";
+  auto subs = mon->session_map.subs.find(type);
+  if (subs == mon->session_map.subs.end())
+    return;
+  for (auto sub : *subs->second) {
+    check_sub(sub);
+  }
+}
+
+void MonmapMonitor::check_sub(Subscription *sub)
+{
+  const auto epoch = mon->monmap->get_epoch();
+  dout(10) << __func__
+          << " monmap next " << sub->next
+          << " have " << epoch << dendl;
+  if (sub->next <= epoch) {
+    mon->send_latest_monmap(sub->session->con.get());
+    if (sub->onetime)
+      mon->session_map.remove_sub(sub);
+    else
+      sub->next = epoch + 1;
+  }
+}
index ecfbe1e1225941edc2c740871ea179e945e3db6e..42fd8afa9108a4eaea17a4c59a20e12f345e607f 100644 (file)
@@ -81,7 +81,12 @@ class MonmapMonitor : public PaxosService {
 
   void tick();
 
- private:
+  void check_sub(Subscription *sub);
+
+private:
+  void check_subs();
+
+private:
   bufferlist monmap_bl;
 };