From: Yan, Zheng Date: Tue, 26 Dec 2017 09:10:32 +0000 (+0800) Subject: mds: calculate other mds' last_epoch_under locally X-Git-Tag: v13.1.0~332^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=376145d9199ef8bdb17b18ca873dec0b588509b2;p=ceph.git mds: calculate other mds' last_epoch_under locally No need to get this information from MHeartbeat Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index a786c796177c..4acd44db5071 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -363,7 +363,7 @@ void MDBalancer::send_heartbeat() for (set::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(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(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(); } } diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index 616379431a6f..3c842873aead 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -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_load; map mds_meta_load; map > mds_import_map; - map mds_last_epoch_under_info; + map mds_last_epoch_under_map; // per-epoch state double my_load = 0; diff --git a/src/messages/MHeartbeat.h b/src/messages/MHeartbeat.h index 730f47f9f205..30650e5ee5cb 100644 --- a/src/messages/MHeartbeat.h +++ b/src/messages/MHeartbeat.h @@ -20,29 +20,24 @@ #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 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& 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; - } } };