]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Don't do rebalancing until the target mds' are in the MDSMap.
authorGreg Farnum <gregf@hq.newdream.net>
Thu, 1 Oct 2009 20:30:00 +0000 (13:30 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 2 Oct 2009 22:22:09 +0000 (15:22 -0700)
This will break rebalancing until the monitor code to
add targets is in place.

src/mds/MDBalancer.cc
src/mds/MDBalancer.h
src/mds/MDS.cc

index e1a2a570e8f7718f646d622eb555b8e4616825d9..4c93a252d50811e54ddd43f820a99dd612cd4dbc 100644 (file)
@@ -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 <vector>
 #include <map>
@@ -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<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)) {
+      //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<double,CDir*>    import_pop_map;
   multimap<int,CDir*>  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
index 8919dbc92b1eafa5196d5e0dfa564591b9791712..8c2d4a8ca45042c2c2854c93ec14c7f547d45a63 100644 (file)
@@ -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),
index e695e43f43fdb958b0be06fc296687f6860508b9..0cc51cb94b303b444bb353667a077a0f6ebd8340 100644 (file)
@@ -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;