From 547876975307fec6773e853a99cedbad6b4926ef Mon Sep 17 00:00:00 2001 From: huanwen ren Date: Thu, 28 Jul 2016 16:05:00 +0800 Subject: [PATCH 1/4] mds/MDBalancer: add err info when ifstream open failure Signed-off-by: huanwen ren --- src/mds/MDBalancer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 784263e9cec..86e38f34189 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -162,7 +162,9 @@ mds_load_t MDBalancer::get_load(utime_t now) ifstream cpu("/proc/loadavg"); if (cpu.is_open()) cpu >> load.cpu_load_avg; - + else + derr << "input file '/proc/loadavg' not found" << dendl; + dout(15) << "get_load " << load << dendl; return load; } From 7c51349ba77fbc101108f39e8cc2ab6c199b23e7 Mon Sep 17 00:00:00 2001 From: huanwen ren Date: Fri, 29 Jul 2016 11:31:03 +0800 Subject: [PATCH 2/4] mds/MDBalancer: some types of definitions are cleanup Signed-off-by: huanwen ren --- src/mds/MDBalancer.cc | 8 ++++---- src/mds/MDBalancer.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 86e38f34189..dcca7956069 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -458,7 +458,7 @@ void MDBalancer::prep_rebalance(int beat) << dendl; } - double total_load = 0; + double total_load = 0.0; multimap load_map; for (mds_rank_t i=mds_rank_t(0); i < mds_rank_t(cluster_size); i++) { map::value_type val(i, mds_load_t(ceph_clock_now(g_ceph_context))); @@ -655,7 +655,7 @@ void MDBalancer::try_rebalance() //<< " .. " << (*it).second << " * " << load_fac << " -> " << amount << dendl;//" .. fudge is " << fudge << dendl; - double have = 0; + double have = 0.0; show_imports(); @@ -1007,7 +1007,7 @@ void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, int who, double amoun dir->pop_spread.hit(now, mds->mdcache->decayrate, who); } - double rd_adj = 0; + double rd_adj = 0.0; if (type == META_POP_IRD && dir->last_popularity_sample < last_sample) { double dir_pop = dir->pop_auth_subtree.get(type).get(now, mds->mdcache->decayrate); // hmm?? @@ -1059,7 +1059,7 @@ void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, int who, double amoun bool hit_subtree = dir->is_auth(); // current auth subtree (if any) bool hit_subtree_nested = dir->is_auth(); // all nested auth subtrees - while (1) { + while (true) { dir->pop_nested.get(type).hit(now, amount); if (rd_adj != 0.0) dir->pop_nested.get(META_POP_IRD).adjust(now, mds->mdcache->decayrate, rd_adj); diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index 68546dbd926..81b00b5e79e 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -55,7 +55,7 @@ class MDBalancer { // per-epoch scatter/gathered info map mds_load; - map mds_meta_load; + map mds_meta_load; map > mds_import_map; // per-epoch state From 7905f31d5eae7de957cece6dd3a9fd71ac52da61 Mon Sep 17 00:00:00 2001 From: huanwen ren Date: Fri, 29 Jul 2016 13:55:57 +0800 Subject: [PATCH 3/4] mds/MDBalancer: redundance cleanup Signed-off-by: huanwen ren --- src/mds/MDBalancer.cc | 95 ++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 65 deletions(-) diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index dcca7956069..782f98873e9 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -554,40 +554,36 @@ void MDBalancer::prep_rebalance(int beat) } } - - if (1) { - if (beat % 2 == 1) { - // old way - dout(15) << " matching big exporters to big importers" << dendl; - // big exporters to big importers - multimap::reverse_iterator ex = exporters.rbegin(); - multimap::iterator im = importers.begin(); - while (ex != exporters.rend() && - im != importers.end()) { - double maxex = get_maxex(ex->second); - double maxim = get_maxim(im->second); - if (maxex < .001 || maxim < .001) break; - try_match(ex->second, maxex, - im->second, maxim); - if (maxex <= .001) ++ex; - if (maxim <= .001) ++im; - } - } else { - // new way - dout(15) << " matching small exporters to big importers" << dendl; - // small exporters to big importers - multimap::iterator ex = exporters.begin(); - multimap::iterator im = importers.begin(); - while (ex != exporters.end() && - im != importers.end()) { - double maxex = get_maxex(ex->second); - double maxim = get_maxim(im->second); - if (maxex < .001 || maxim < .001) break; - try_match(ex->second, maxex, - im->second, maxim); - if (maxex <= .001) ++ex; - if (maxim <= .001) ++im; - } + // old way + if (beat % 2 == 1) { + dout(15) << " matching big exporters to big importers" << dendl; + // big exporters to big importers + multimap::reverse_iterator ex = exporters.rbegin(); + multimap::iterator im = importers.begin(); + while (ex != exporters.rend() && + im != importers.end()) { + double maxex = get_maxex(ex->second); + double maxim = get_maxim(im->second); + if (maxex < .001 || maxim < .001) break; + try_match(ex->second, maxex, + im->second, maxim); + if (maxex <= .001) ++ex; + if (maxim <= .001) ++im; + } + } else { // new way + dout(15) << " matching small exporters to big importers" << dendl; + // small exporters to big importers + multimap::iterator ex = exporters.begin(); + multimap::iterator im = importers.begin(); + while (ex != exporters.end() && + im != importers.end()) { + double maxex = get_maxex(ex->second); + double maxim = get_maxim(im->second); + if (maxex < .001 || maxim < .001) break; + try_match(ex->second, maxex, + im->second, maxim); + if (maxex <= .001) ++ex; + if (maxim <= .001) ++im; } } } @@ -938,43 +934,12 @@ void MDBalancer::hit_inode(utime_t now, CInode *in, int type, int who) if (in->get_parent_dn()) hit_dir(now, in->get_parent_dn()->get_dir(), type, who); } -/* - // hit me - in->popularity[MDS_POP_JUSTME].pop[type].hit(now); - in->popularity[MDS_POP_NESTED].pop[type].hit(now); - if (in->is_auth()) { - in->popularity[MDS_POP_CURDOM].pop[type].hit(now); - in->popularity[MDS_POP_ANYDOM].pop[type].hit(now); - - dout(20) << "hit_inode " << type << " pop " - << in->popularity[MDS_POP_JUSTME].pop[type].get(now) << " me, " - << in->popularity[MDS_POP_NESTED].pop[type].get(now) << " nested, " - << in->popularity[MDS_POP_CURDOM].pop[type].get(now) << " curdom, " - << in->popularity[MDS_POP_CURDOM].pop[type].get(now) << " anydom" - << " on " << *in - << dendl; - } else { - dout(20) << "hit_inode " << type << " pop " - << in->popularity[MDS_POP_JUSTME].pop[type].get(now) << " me, " - << in->popularity[MDS_POP_NESTED].pop[type].get(now) << " nested, " - << " on " << *in - << dendl; - } - - // hit auth up to import - CDir *dir = in->get_parent_dir(); - if (dir) hit_dir(now, dir, type); -*/ - void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, int who, double amount) { // hit me double v = dir->pop_me.get(type).hit(now, amount); - //if (dir->ino() == inodeno_t(0x10000000000)) - //dout(0) << "hit_dir " << type << " pop " << v << " in " << *dir << dendl; - // split/merge if (g_conf->mds_bal_frag && g_conf->mds_bal_fragment_interval > 0 && !dir->inode->is_base() && // not root/base (for now at least) From ff9a5cb2ef8c55b24a357668372d4a7325268561 Mon Sep 17 00:00:00 2001 From: huanwen ren Date: Sat, 30 Jul 2016 13:50:24 +0800 Subject: [PATCH 4/4] mds/MDBalancer: change OPT_FLOAT to OPT_DOUBLE utime_t convert double in MDBalancer::tick(), so g_conf->mds_bal_sample_interval should be set OPT_DOUBLE Signed-off-by: huanwen ren --- src/common/config_opts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 04ac61832e5..46c29ae533f 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -475,7 +475,7 @@ OPTION(mds_log_events_per_segment, OPT_INT, 1024) OPTION(mds_log_segment_size, OPT_INT, 0) // segment size for mds log, default to default file_layout_t OPTION(mds_log_max_segments, OPT_U32, 30) OPTION(mds_log_max_expiring, OPT_INT, 20) -OPTION(mds_bal_sample_interval, OPT_FLOAT, 3.0) // every 5 seconds +OPTION(mds_bal_sample_interval, OPT_DOUBLE, 3.0) // every 3 seconds OPTION(mds_bal_replicate_threshold, OPT_FLOAT, 8000) OPTION(mds_bal_unreplicate_threshold, OPT_FLOAT, 0) OPTION(mds_bal_frag, OPT_BOOL, false)