From: John Spray Date: Mon, 6 Jul 2015 12:19:31 +0000 (+0100) Subject: mds: separate most of MDSRank from dispatcher-like parts X-Git-Tag: v9.1.0~406^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=49d0f71258cf29fcc0d3cb97d9c8d3141a70fcb7;p=ceph.git mds: separate most of MDSRank from dispatcher-like parts 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 --- diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 9dff88e5e3c2..98486c9a1674 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -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); diff --git a/src/mds/MDS.h b/src/mds/MDS.h index 052d72268022..34e482077dd3 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -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); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 1b35c41a54fd..fe1e6d790b6b 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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 log_to_monitors; map 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 args) +bool MDSRankDispatcher::handle_command_legacy(std::vector args) { if (args[0] == "dumpcache") { if (args.size() > 1) @@ -2370,3 +2370,18 @@ bool MDSRank::handle_command_legacy(std::vector 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_) +{} + diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index e322676ecbd0..7307d187b9ed 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -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 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 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 { \