]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: separate most of MDSRank from dispatcher-like parts
authorJohn Spray <john.spray@redhat.com>
Mon, 6 Jul 2015 12:19:31 +0000 (13:19 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 28 Jul 2015 08:05:08 +0000 (09:05 +0100)
This is the separation between the parts of MDSRank
that are exposed downwards to subsystems, and
the parts that are exposed upwards to the daemon.

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

index 9dff88e5e3c293842499c5c2431a0cbd61198abb..98486c9a1674ab10abbf60640c39565cb745235f 100644 (file)
@@ -914,8 +914,8 @@ void MDS::handle_mds_map(MMDSMap *m)
 
     // Did I previously not hold a rank?  Initialize!
     if (mds_rank == NULL) {
-      mds_rank = new MDSRank(mds_lock, clog, timer, beacon, mdsmap, messenger,
-          monc, objecter,
+      mds_rank = new MDSRankDispatcher(mds_lock, clog, timer, beacon, mdsmap,
+          messenger, monc, objecter,
           new C_VoidFn(this, &MDS::respawn),
           new C_VoidFn(this, &MDS::suicide));
       mds_rank->init(whoami, incarnation);
index 052d72268022ec92ea1948628aae8a83ab26452d..34e482077dd3be119d38c250a6b045e1b890acaa 100644 (file)
@@ -98,7 +98,7 @@ class MDS : public Dispatcher, public md_config_obs_t {
   LogClient    log_client;
   LogChannelRef clog;
 
-  MDSRank *mds_rank;
+  MDSRankDispatcher *mds_rank;
 
  public:
   MDS(const std::string &n, Messenger *m, MonClient *mc);
index 1b35c41a54fd7ff53449f8dbe9da67e2011bd23d..fe1e6d790b6b8a6855aa09fcf0d81c9ac0e5eebf 100644 (file)
@@ -130,7 +130,7 @@ MDSRank::~MDSRank()
   respawn_hook = NULL;
 }
 
-void MDSRank::init(mds_rank_t rank_, int incarnation_)
+void MDSRankDispatcher::init(mds_rank_t rank_, int incarnation_)
 {
   update_log_config();
   create_logger();
@@ -147,7 +147,7 @@ void MDSRank::init(mds_rank_t rank_, int incarnation_)
   finisher->start();
 }
 
-void MDSRank::tick()
+void MDSRankDispatcher::tick()
 {
   heartbeat_reset();
 
@@ -197,7 +197,7 @@ void MDSRank::tick()
   }
 }
 
-void MDSRank::shutdown()
+void MDSRankDispatcher::shutdown()
 {
   // It should never be possible for shutdown to get called twice, because
   // anyone picking up mds_lock checks if stopping is true and drops
@@ -391,7 +391,7 @@ void MDSRank::ProgressThread::shutdown()
   }
 }
 
-bool MDSRank::ms_dispatch(Message *m)
+bool MDSRankDispatcher::ms_dispatch(Message *m)
 {
   bool ret;
   inc_dispatch_depth();
@@ -1364,7 +1364,7 @@ void MDSRank::stopping_done()
 
 // <<<<<<<<
 
-void MDSRank::handle_mds_map(
+void MDSRankDispatcher::handle_mds_map(
     MMDSMap *m,
     MDSMap *oldmap)
 {
@@ -1628,7 +1628,7 @@ void MDSRank::handle_mds_failure(mds_rank_t who)
   snapclient->handle_mds_failure(who);
 }
 
-bool MDSRank::handle_asok_command(
+bool MDSRankDispatcher::handle_asok_command(
     std::string command, cmdmap_t& cmdmap, Formatter *f,
                    std::ostream& ss)
 {
@@ -2145,7 +2145,7 @@ bool MDSRank::command_dirfrag_ls(
   return true;
 }
 
-void MDSRank::update_log_config()
+void MDSRankDispatcher::update_log_config()
 {
   map<string,string> log_to_monitors;
   map<string,string> log_to_syslog;
@@ -2244,7 +2244,7 @@ void MDSRank::check_ops_in_flight()
   return;
 }
 
-void MDSRank::handle_osd_map()
+void MDSRankDispatcher::handle_osd_map()
 {
   if (is_active() && snapserver) {
     snapserver->check_osd_map(true);
@@ -2260,7 +2260,7 @@ void MDSRank::handle_osd_map()
   objecter->maybe_request_map();
 }
 
-bool MDSRank::kill_session(int64_t session_id)
+bool MDSRankDispatcher::kill_session(int64_t session_id)
 {
   Session *session = sessionmap.get_session(entity_name_t(CEPH_ENTITY_TYPE_CLIENT, session_id));
 
@@ -2287,7 +2287,7 @@ void MDSRank::bcast_mds_map()
 }
 
 
-bool MDSRank::handle_command_legacy(std::vector<std::string> args)
+bool MDSRankDispatcher::handle_command_legacy(std::vector<std::string> args)
 {
   if (args[0] == "dumpcache") {
     if (args.size() > 1)
@@ -2370,3 +2370,18 @@ bool MDSRank::handle_command_legacy(std::vector<std::string> args)
   return true;
 }
 
+MDSRankDispatcher::MDSRankDispatcher(
+    Mutex &mds_lock_,
+    LogChannelRef &clog_,
+    SafeTimer &timer_,
+    Beacon &beacon_,
+    MDSMap *& mdsmap_,
+    Messenger *msgr,
+    MonClient *monc_,
+    Objecter *objecter_,
+    Context *respawn_hook_,
+    Context *suicide_hook_)
+  : MDSRank(mds_lock_, clog_, timer_, beacon_, mdsmap_, msgr, monc_, objecter_,
+            respawn_hook_, suicide_hook_)
+{}
+
index e322676ecbd0ff52234181172419d7d686795aab..7307d187b9ed4e43325080ebb31fa67c8b41d3ea 100644 (file)
@@ -113,15 +113,6 @@ class MMDSMap;
  * The public part of this class's interface is what's exposed to all
  * the various subsystems (server, mdcache, etc), such as pointers
  * to the other subsystems, and message-sending calls.
- *
- * FIXME This isn't quite pure, because we also contain all the dispatch
- * mechanisms that operate on the subsystems.  Perhaps we should
- * have an MDSRank parent that contains everything for the subsystems,
- * and an MDSRankDispatcher that contains all the dispatch logic.  That's
- * awkward right because advance_queues etc need to know how to do dispatch
- * on the queues, and the queues need to be exposed to the subsystems so that
- * they can enqueue things.  Perhaps the MDSRank base should have some pure
- * virtual functions for things like enqueuing messages for retry.
  */
 class MDSRank {
   public:
@@ -374,23 +365,6 @@ class MDSRank {
 
     int get_req_rate() { return logger->get(l_mds_request); }
 
-    // FIXME: interface for MDSDaemon to call, don't really want to expose
-    // this to every subsystem that carries an MDSRank reference though
-    // >>>
-    void init(mds_rank_t rank, int incarnation);
-    void tick();
-    void shutdown();
-    bool handle_asok_command(std::string command, cmdmap_t& cmdmap,
-                             Formatter *f, std::ostream& ss);
-    void handle_mds_map(MMDSMap *m, MDSMap *oldmap);
-    void handle_osd_map();
-    bool kill_session(int64_t session_id);
-    void update_log_config();
-    bool handle_command_legacy(std::vector<std::string> args);
-
-    // Call into me from MDS::ms_dispatch
-    bool ms_dispatch(Message *m);
-
   protected:
     void command_scrub_path(Formatter *f, const string& path);
     void command_flush_path(Formatter *f, const string& path);
@@ -498,6 +472,41 @@ public:
   }
 };
 
+/**
+ * The aspect of MDSRank exposed to MDSDaemon but not subsystems: i.e.
+ * the service/dispatcher stuff like init/shutdown that subsystems should
+ * never touch.
+ */
+class MDSRankDispatcher : public MDSRank
+{
+public:
+  void init(mds_rank_t rank, int incarnation);
+  void tick();
+  void shutdown();
+  bool handle_asok_command(std::string command, cmdmap_t& cmdmap,
+                           Formatter *f, std::ostream& ss);
+  void handle_mds_map(MMDSMap *m, MDSMap *oldmap);
+  void handle_osd_map();
+  bool kill_session(int64_t session_id);
+  void update_log_config();
+  bool handle_command_legacy(std::vector<std::string> args);
+
+  // Call into me from MDS::ms_dispatch
+  bool ms_dispatch(Message *m);
+
+  MDSRankDispatcher(
+      Mutex &mds_lock_,
+      LogChannelRef &clog_,
+      SafeTimer &timer_,
+      Beacon &beacon_,
+      MDSMap *& mdsmap_,
+      Messenger *msgr,
+      MonClient *monc_,
+      Objecter *objecter_,
+      Context *respawn_hook_,
+      Context *suicide_hook_);
+};
+
 // This utility for MDS and MDSRank dispatchers.
 #define ALLOW_MESSAGES_FROM(peers) \
 do { \