]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Pull my_target checking out into a function targets_safe
authorGreg Farnum <gregf@hq.newdream.net>
Thu, 1 Oct 2009 20:51:22 +0000 (13:51 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 2 Oct 2009 22:22:09 +0000 (15:22 -0700)
src/mds/MDBalancer.cc
src/mds/MDBalancer.h

index 4c93a252d50811e54ddd43f820a99dd612cd4dbc..fc2380cfa7d8435f5734599e016c61c5b28d112e 100644 (file)
@@ -494,22 +494,14 @@ void MDBalancer::do_rebalance(int beat)
 
 void MDBalancer::try_rebalance()
 {
-  //check if the current MonMap has all our targets
-  for (map<int,double>::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)) {
+  if (!targets_safe()) {
       //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()).
+  if (mds->mdsmap->get_mds_info(mds->whoami).
       export_targets.size() != my_targets.size())
     send_targets_message();
   
@@ -669,7 +661,6 @@ void MDBalancer::try_rebalance()
   }
 
   dout(5) << "rebalance done" << dendl;
-  send_offload_complete_message();
   show_imports();
 }
 
@@ -679,6 +670,25 @@ inline void MDBalancer::send_targets_message()
   mds->monc->send_mon_message(m);
 }
 
+/* returns true if all my_target MDS are in the MDSMap.
+ */
+bool MDBalancer::targets_safe() {
+  //get MonMap's idea of my_targets
+  const set<int32_t>& map_targets = 
+    mds->mdsmap->get_mds_info(mds->whoami).export_targets;
+  //check if the current MonMap has all our targets
+  for (map<int,double>::iterator i = my_targets.begin();
+       i != my_targets.end();
+       ++i) {
+    if (!map_targets.count(i->first)) {
+      dout(20) << "At least one target mds (" << i->first
+              << ") not in MDSMap" << dendl;
+      return false;
+    }
+  }
+  return true;
+}
+
 void MDBalancer::find_exports(CDir *dir, 
                               double amount, 
                               list<CDir*>& exports, 
index 8c2d4a8ca45042c2c2854c93ec14c7f547d45a63..116a9698b277c9f2f40a200eca5a12b6ef2db4d0 100644 (file)
@@ -60,6 +60,9 @@ class MDBalancer {
   map<int,double> my_targets;
   map<int,double> imported;
   map<int,double> exported;
+  //Check if all our current offload targets are in MDSMap
+  bool targets_safe();
+
 
   double try_match(int ex, double& maxex,
                    int im, double& maxim);
@@ -71,6 +74,7 @@ class MDBalancer {
   }
 
 private:
+  //send an MMDSOffloadTargets message to the monitor
   void send_targets_message();
 
 public: