]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: promote Beacon to be a Dispatcher
authorJohn Spray <john.spray@redhat.com>
Fri, 22 Aug 2014 00:17:55 +0000 (01:17 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 2 Sep 2014 13:06:24 +0000 (14:06 +0100)
This allows it to handle its own MSG_MDS_BEACON
messages from the mon, outside of mds_lock.

This is less important than the sending of beacons
being outside the lock, but still nice to have and
gets all the beacon messaging in one place.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/Beacon.cc
src/mds/Beacon.h
src/mds/MDS.cc
src/mds/MDS.h

index e19ec3faa156921a5647b8ccca2e343c714adc51..667a7d7f2f5ee432fd1149fe27550ba27124311d 100644 (file)
@@ -24,8 +24,8 @@
 #define dout_prefix *_dout << "mds.beacon." << name << ' '
 
 
-Beacon::Beacon(MonClient *monc_, std::string name_) :
-  lock("Beacon"), monc(monc_), timer(g_ceph_context, lock), name(name_)
+Beacon::Beacon(CephContext *cct_, MonClient *monc_, std::string name_) :
+  Dispatcher(cct_), lock("Beacon"), monc(monc_), timer(g_ceph_context, lock), name(name_)
 {
   last_seq = 0;
   sender = NULL;
@@ -69,6 +69,20 @@ void Beacon::shutdown()
 }
 
 
+bool Beacon::ms_dispatch(Message *m)
+{
+  if (m->get_type() == MSG_MDS_BEACON) {
+    if (m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MON) {
+      handle_mds_beacon(static_cast<MMDSBeacon*>(m));
+    }
+  }
+
+  // Let message fall through to MDS so that we get the execution of
+  // his finished_queue and waiting_for_nolaggy stuff.
+  return false;
+}
+
+
 /**
  * Update lagginess state based on response from remote MDSMonitor
  *
@@ -106,8 +120,6 @@ void Beacon::handle_mds_beacon(MMDSBeacon *m)
     dout(10) << "handle_mds_beacon " << ceph_mds_state_name(m->get_state())
             << " seq " << m->get_seq() << " dne" << dendl;
   }
-
-  m->put();
 }
 
 
index deaeab0243f9dffd6ea9e399af39664e16a744f5..50d17dfd1c8f1676be309d2f867d57002b09c9ae 100644 (file)
 #include "include/types.h"
 #include "include/Context.h"
 #include "common/Mutex.h"
+#include "msg/Dispatcher.h"
 
 class MonClient;
 class MMDSBeacon;
+class Message;
 
 
 /**
@@ -33,8 +35,9 @@ class MMDSBeacon;
  * we keep copies of the data needed to generate beacon messages.  The MDS is
  * responsible for calling Beacon::notify_* when things change.
  */
-class Beacon
+class Beacon : public Dispatcher
 {
+  //CephContext *cct;
   mutable Mutex lock;
   MonClient*    monc;
   SafeTimer     timer;
@@ -71,12 +74,17 @@ class Beacon
   void _send();
 
 public:
-  Beacon(MonClient *monc_, std::string name);
+  Beacon(CephContext *cct_, MonClient *monc_, std::string name);
   ~Beacon();
 
   void init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_, int standby_rank_, std::string const &standby_name_);
   void shutdown();
 
+  bool ms_dispatch(Message *m); 
+  void ms_handle_connect(Connection *c) {}
+  bool ms_handle_reset(Connection *c) {return false;}
+  void ms_handle_remote_reset(Connection *c) {}
+
   void notify_mdsmap(MDSMap const *mdsmap);
   void notify_want_state(MDSMap::DaemonState const newstate);
 
index 96edc89add84a5d7fb505f307ad9cf40034e7ebb..3d832b8151d9a3c107587f139ac4302f770edeb9 100644 (file)
@@ -83,7 +83,7 @@ MDS::MDS(const std::string &n, Messenger *m, MonClient *mc) :
   Dispatcher(m->cct),
   mds_lock("MDS::mds_lock"),
   timer(m->cct, mds_lock),
-  beacon(mc, n),
+  beacon(m->cct, mc, n),
   authorize_handler_cluster_registry(new AuthAuthorizeHandlerRegistry(m->cct,
                                                                      m->cct->_conf->auth_supported.length() ?
                                                                      m->cct->_conf->auth_supported :
@@ -569,6 +569,7 @@ int MDS::init(MDSMap::DaemonState wanted_state)
   objecter->init();
 
   messenger->add_dispatcher_tail(objecter);
+  messenger->add_dispatcher_tail(&beacon);
   messenger->add_dispatcher_tail(this);
 
   // get monmap
@@ -1851,9 +1852,12 @@ bool MDS::handle_core_message(Message *m)
     break;
   case MSG_MDS_BEACON:
     ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
-    beacon.handle_mds_beacon(static_cast<MMDSBeacon*>(m));
+    // no-op, Beacon handles this on our behalf but we listen for the
+    // message to get the side effect of handling finished_queue and
+    // waiting_for_nolaggy at end of MDS dispatch.
+    m->put();
     break;
-    
+
     // misc
   case MSG_MON_COMMAND:
     ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
@@ -2299,3 +2303,14 @@ void MDS::ms_handle_accept(Connection *con)
     s->put();
   }
 }
+
+void MDS::set_want_state(MDSMap::DaemonState newstate)
+{
+  if (want_state != newstate) {
+    dout(10) << __func__ << " "
+      << ceph_mds_state_name(want_state) << " -> "
+      << ceph_mds_state_name(newstate) << dendl;
+    want_state = newstate;
+    beacon.notify_want_state(newstate);
+  }
+}
index 3f5c2514d70ea9f8ab43cd875ee51177a647fb73..a69885d47433e1c67f1e9a8db0e9e79086c4c807 100644 (file)
@@ -146,11 +146,7 @@ class MDS : public Dispatcher, public md_config_obs_t {
 
  private:
   Beacon  beacon;
-  void set_want_state(MDSMap::DaemonState newstate)
-  {
-    want_state = newstate;
-    beacon.notify_want_state(newstate);
-  }
+  void set_want_state(MDSMap::DaemonState newstate);
  public:
   utime_t get_laggy_until() {return beacon.get_laggy_until();}