]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: calculate other mds' last_epoch_under locally
authorYan, Zheng <zyan@redhat.com>
Tue, 26 Dec 2017 09:10:32 +0000 (17:10 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 10 Apr 2018 01:19:48 +0000 (09:19 +0800)
No need to get this information from MHeartbeat

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDBalancer.cc
src/mds/MDBalancer.h
src/messages/MHeartbeat.h

index a786c796177c0f6837b330fd415803ba8ea3154c..4acd44db5071b13971ae9fc0cd491d1c86ea6158 100644 (file)
@@ -363,7 +363,7 @@ void MDBalancer::send_heartbeat()
   for (set<mds_rank_t>::iterator p = up.begin(); p != up.end(); ++p) {
     if (*p == mds->get_nodeid())
       continue;
-    MHeartbeat *hb = new MHeartbeat(load, beat_epoch, last_epoch_under);
+    MHeartbeat *hb = new MHeartbeat(load, beat_epoch);
     hb->get_import_map() = import_map;
     messenger->send_message(hb,
                             mds->mdsmap->get_inst(*p));
@@ -417,7 +417,6 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m)
 
   mds_load[who] = m->get_load();
   mds_import_map[who] = m->get_import_map();
-  mds_last_epoch_under_info[who] = m->get_last_epoch_under();
 
   {
     unsigned cluster_size = mds->get_mds_map()->get_num_in_mds();
@@ -646,13 +645,18 @@ void MDBalancer::prep_rebalance(int beat)
            << dendl;
 
     // under or over?
-    if (my_load < target_load * (1.0 + g_conf->mds_bal_min_rebalance)) {
+    for (auto p : load_map) {
+      if (p.first < target_load * (1.0 + g_conf->mds_bal_min_rebalance)) {
+       dout(5) << " mds." << p.second << " is underloaded or barely overloaded." << dendl;
+       mds_last_epoch_under_map[p.second] = beat_epoch;
+      }
+    }
+
+    int last_epoch_under = mds_last_epoch_under_map[whoami];
+    if (last_epoch_under == beat_epoch) {
       dout(5) << "  i am underloaded or barely overloaded, doing nothing." << dendl;
-      last_epoch_under = beat_epoch;
-      mds->mdcache->show_subtrees();
       return;
     }
-
     // am i over long enough?
     if (last_epoch_under && beat_epoch - last_epoch_under < 2) {
       dout(5) << "  i am overloaded, but only for " << (beat_epoch - last_epoch_under) << " epochs" << dendl;
@@ -675,13 +679,13 @@ void MDBalancer::prep_rebalance(int beat)
        dout(15) << "   mds." << it->second << " is importer" << dendl;
        importers.insert(pair<double,mds_rank_t>(it->first,it->second));
        importer_set.insert(it->second);
-      } else if (it->first > target_load * (1.0 + g_conf->mds_bal_min_rebalance)) {
-        int mds_last_epoch_under = (it->second == whoami) ? 0 : mds_last_epoch_under_info[it->second];
-        if (!mds_last_epoch_under || beat_epoch - mds_last_epoch_under >= 2) {
+      } else {
+       int mds_last_epoch_under = mds_last_epoch_under_map[it->second];
+       if (!(mds_last_epoch_under && beat_epoch - mds_last_epoch_under < 2)) {
          dout(15) << "   mds." << it->second << " is exporter" << dendl;
          exporters.insert(pair<double,mds_rank_t>(it->first,it->second));
          exporter_set.insert(it->second);
-        }
+       }
       }
     }
 
@@ -1291,7 +1295,7 @@ void MDBalancer::adjust_pop_for_rename(CDir *pdir, CDir *dir, utime_t now, bool
 void MDBalancer::handle_mds_failure(mds_rank_t who)
 {
   if (0 == who) {
-    last_epoch_under = 0;
+    mds_last_epoch_under_map.clear();
   }
 }
 
index 616379431a6ff6aea0aa04fd639c04204e91ef29..3c842873aead776e08dbe0ac8000a8b045ddee0b 100644 (file)
@@ -120,7 +120,6 @@ private:
   MonClient *mon_client;
   int beat_epoch = 0;
 
-  int last_epoch_under = 0;
   string bal_code;
   string bal_version;
 
@@ -141,7 +140,7 @@ private:
   map<mds_rank_t, mds_load_t>  mds_load;
   map<mds_rank_t, double>       mds_meta_load;
   map<mds_rank_t, map<mds_rank_t, float> > mds_import_map;
-  map<mds_rank_t, int> mds_last_epoch_under_info;
+  map<mds_rank_t, int> mds_last_epoch_under_map;
 
   // per-epoch state
   double my_load = 0;
index 730f47f9f205ff76e7b5f99f61e486d3a03bb9c1..30650e5ee5cbf42acc35ba3f7d90c92ebfe32958 100644 (file)
 #include "msg/Message.h"
 
 class MHeartbeat : public Message {
-  static const int HEAD_VERSION = 2;
-  static const int COMPAT_VERSION = 1;
   mds_load_t load;
   __s32        beat = 0;
-  __s32        last_epoch_under = 0;
   map<mds_rank_t, float> import_map;
 
  public:
   mds_load_t& get_load() { return load; }
   int get_beat() { return beat; }
-  int get_last_epoch_under() { return last_epoch_under; }
 
   map<mds_rank_t, float>& get_import_map() {
     return import_map;
   }
 
   MHeartbeat()
-    : Message(MSG_MDS_HEARTBEAT, HEAD_VERSION, COMPAT_VERSION), load(utime_t()) { }
-  MHeartbeat(mds_load_t& load, int beat, int last_epoch_under)
-    : Message(MSG_MDS_HEARTBEAT, HEAD_VERSION, COMPAT_VERSION),
+    : Message(MSG_MDS_HEARTBEAT), load(utime_t()) { }
+  MHeartbeat(mds_load_t& load, int beat)
+    : Message(MSG_MDS_HEARTBEAT),
       load(load) {
     this->beat = beat;
-    this->last_epoch_under = last_epoch_under;
   }
 private:
   ~MHeartbeat() override {}
@@ -55,7 +50,6 @@ public:
     encode(load, payload);
     encode(beat, payload);
     encode(import_map, payload);
-    encode(last_epoch_under, payload);
   }
   void decode_payload() override {
     bufferlist::iterator p = payload.begin();
@@ -63,11 +57,6 @@ public:
     decode(load, now, p);
     decode(beat, p);
     decode(import_map, p);
-    if (header.version >= 2) {
-      decode(last_epoch_under, p);
-    } else {
-      last_epoch_under = 0;
-    }
   }
 
 };