From: Greg Farnum Date: Thu, 1 Oct 2009 20:30:00 +0000 (-0700) Subject: mds: Don't do rebalancing until the target mds' are in the MDSMap. X-Git-Tag: v0.16~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3e36d3202a64d9ba0e55cf22554e764c221451ed;p=ceph.git mds: Don't do rebalancing until the target mds' are in the MDSMap. This will break rebalancing until the monitor code to add targets is in place. --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index e1a2a570e8f77..4c93a252d5081 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -16,6 +16,7 @@ #include "MDBalancer.h" #include "MDS.h" +#include "mon/MonClient.h" #include "MDSMap.h" #include "CInode.h" #include "CDir.h" @@ -25,6 +26,7 @@ #include "include/Context.h" #include "msg/Messenger.h" #include "messages/MHeartbeat.h" +#include "messages/MMDSLoadTargets.h" #include #include @@ -484,6 +486,7 @@ void MDBalancer::do_rebalance(int beat) } } } + send_targets_message(); try_rebalance(); } @@ -491,6 +494,25 @@ void MDBalancer::do_rebalance(int beat) void MDBalancer::try_rebalance() { + //check if the current MonMap has all our targets + for (map::iterator i = my_targets.begin(); + i != my_targets.end(); + ++i) { + if (!mds->mdsmap->get_mds_info(mds->messenger->get_myaddr()). + export_targets.count(i->first)) { + //can't rebalance until it has all our targets! + dout(10) << "MDBalancer::try_rebalance can't rebalance when mds is missing some of our targets! Resending targets message" << dendl; + send_targets_message(); + return; + } + } + //Hurrah, all our targets are included in MDSMap! Proceed + + //if the MDSMap has old targets we don't want... + if (mds->mdsmap->get_mds_info(mds->messenger->get_myaddr()). + export_targets.size() != my_targets.size()) + send_targets_message(); + // make a sorted list of my imports map import_pop_map; multimap import_from_map; @@ -647,11 +669,15 @@ void MDBalancer::try_rebalance() } dout(5) << "rebalance done" << dendl; + send_offload_complete_message(); show_imports(); - } - +inline void MDBalancer::send_targets_message() +{ + MMDSLoadTargets* m = new MMDSLoadTargets(my_targets); + mds->monc->send_mon_message(m); +} void MDBalancer::find_exports(CDir *dir, double amount, @@ -771,9 +797,6 @@ void MDBalancer::find_exports(CDir *dir, } - - - void MDBalancer::hit_inode(utime_t now, CInode *in, int type, int who) { // hit inode diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index 8919dbc92b1ea..8c2d4a8ca4504 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -70,7 +70,10 @@ class MDBalancer { return mds_meta_load[ex] - target_load - exported[ex]; } - public: +private: + void send_targets_message(); + +public: MDBalancer(MDS *m) : mds(m), beat_epoch(0), diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index e695e43f43fdb..0cc51cb94b303 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -765,6 +765,8 @@ void MDS::handle_mds_map(MMDSMap *m) mdcache->migrator->handle_mds_failure_or_stop(*p); } + balancer->try_rebalance(); + out: delete m; delete oldmap;