From: John Spray Date: Fri, 3 Jul 2015 10:40:41 +0000 (+0100) Subject: mds: pass MonClient ref into snapserver & mdbalancer X-Git-Tag: v9.1.0~406^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e21c699e2fa300d0536f03b6902b4104f29fec15;p=ceph.git mds: pass MonClient ref into snapserver & mdbalancer Thereby avoid having to expose methods on MDSRank for them to send mon messages. Signed-off-by: John Spray --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 937cc1b49dc..e806e52d8de 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -805,8 +805,8 @@ bool MDBalancer::check_targets() dout(10) << "check_targets have " << map_targets << " need " << need_targets << " want " << want_targets << dendl; if (send) { - MMDSLoadTargets* m = new MMDSLoadTargets(mds_gid_t(mds->get_global_id()), want_targets); - mds->send_mon_message(m); + MMDSLoadTargets* m = new MMDSLoadTargets(mds_gid_t(mon_client->get_global_id()), want_targets); + mon_client->send_mon_message(m); } return ok; } diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index 9cdb012875a..68546dbd926 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -33,11 +33,13 @@ class MHeartbeat; class CInode; class CDir; class Messenger; +class MonClient; class MDBalancer { protected: MDSRank *mds; Messenger *messenger; + MonClient *mon_client; int beat_epoch; int last_epoch_under; @@ -75,9 +77,10 @@ class MDBalancer { } public: - MDBalancer(MDSRank *m, Messenger *msgr) : + MDBalancer(MDSRank *m, Messenger *msgr, MonClient *monc) : mds(m), messenger(msgr), + mon_client(monc), beat_epoch(0), last_epoch_under(0), last_epoch_over(0), my_load(0.0), target_load(0.0) { } diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index edf7e751705..1b35c41a54f 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -77,10 +77,10 @@ MDSRank::MDSRank( mdcache = new MDCache(this); mdlog = new MDLog(this); - balancer = new MDBalancer(this, messenger); + balancer = new MDBalancer(this, messenger, monc); inotable = new InoTable(this); - snapserver = new SnapServer(this); + snapserver = new SnapServer(this, monc); snapclient = new SnapClient(this); server = new Server(this); @@ -862,18 +862,6 @@ utime_t MDSRank::get_laggy_until() const return beacon.get_laggy_until(); } -// FIXME maybe instead of exposing this to the world, we should just -// share a MonClient reference with the guys who need it (balancer+snapserver) -void MDSRank::send_mon_message(Message *m) -{ - monc->send_mon_message(m); -} - -uint64_t MDSRank::get_global_id() const -{ - return monc->get_global_id(); -} - bool MDSRank::is_daemon_stopping() const { return stopping; diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index 8887233a226..e322676ecbd 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -372,10 +372,6 @@ class MDSRank { MDSMap *get_mds_map() { return mdsmap; } - // Access to monc functionality needed by balancer and snapserver - uint64_t get_global_id() const; - void send_mon_message(Message *m); - int get_req_rate() { return logger->get(l_mds_request); } // FIXME: interface for MDSDaemon to call, don't really want to expose diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 6da4bb9339e..557b035c0db 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -283,7 +283,7 @@ void SnapServer::check_osd_map(bool force) if (!all_purge.empty()) { dout(10) << "requesting removal of " << all_purge << dendl; MRemoveSnaps *m = new MRemoveSnaps(all_purge); - mds->send_mon_message(m); + mon_client->send_mon_message(m); } last_checked_osdmap = version; diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index ce593b92202..65177beff66 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -19,11 +19,11 @@ #include "snap.h" class MDSRank; +class MonClient; class SnapServer : public MDSTableServer { -public: - protected: + MonClient *mon_client; snapid_t last_snap; map snaps; map > need_to_purge; @@ -35,8 +35,9 @@ protected: version_t last_checked_osdmap; public: - SnapServer(MDSRank *m) : MDSTableServer(m, TABLE_SNAP), - last_checked_osdmap(0) { } + SnapServer(MDSRank *m, MonClient *monc) + : MDSTableServer(m, TABLE_SNAP), mon_client(monc), last_checked_osdmap(0) + {} void reset_state(); void encode_server_state(bufferlist& bl) const {