From dc41ec6702ea23418800e9b97b832ce2b00612e9 Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 11 Sep 2007 04:11:37 +0000 Subject: [PATCH] load_spread git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1825 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/mds/CDir.h | 2 ++ trunk/ceph/mds/MDBalancer.cc | 14 ++++++++++---- trunk/ceph/mds/MDBalancer.h | 4 ++-- trunk/ceph/mds/Server.cc | 4 ++-- trunk/ceph/mds/mdstypes.h | 30 ++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/trunk/ceph/mds/CDir.h b/trunk/ceph/mds/CDir.h index 691759325e85a..d267373d5f70c 100644 --- a/trunk/ceph/mds/CDir.h +++ b/trunk/ceph/mds/CDir.h @@ -195,6 +195,8 @@ protected: utime_t last_popularity_sample; + load_spread_t pop_spread; + // and to provide density int num_dentries_nested; int num_dentries_auth_subtree; diff --git a/trunk/ceph/mds/MDBalancer.cc b/trunk/ceph/mds/MDBalancer.cc index a4ad7a10c0f93..7022d3f98c914 100644 --- a/trunk/ceph/mds/MDBalancer.cc +++ b/trunk/ceph/mds/MDBalancer.cc @@ -766,13 +766,13 @@ void MDBalancer::find_exports(CDir *dir, -void MDBalancer::hit_inode(utime_t now, CInode *in, int type) +void MDBalancer::hit_inode(utime_t now, CInode *in, int type, int who) { // hit inode in->pop.get(type).hit(now); if (in->get_parent_dir()) - hit_dir(now, in->get_parent_dir(), type); + hit_dir(now, in->get_parent_dir(), type, who); } /* // hit me @@ -803,7 +803,7 @@ void MDBalancer::hit_inode(utime_t now, CInode *in, int type) */ -void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, double amount) +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); @@ -823,13 +823,19 @@ void MDBalancer::hit_dir(utime_t now, CDir *dir, int type, double amount) } // replicate? + if (type == META_POP_IRD) + dir->pop_spread.hit(now, who); + double rd_adj = 0; if (type == META_POP_IRD && dir->last_popularity_sample < last_sample) { float dir_pop = dir->pop_auth_subtree.get(type).get(now); // hmm?? dir->last_popularity_sample = last_sample; + float pop_sp = dir->pop_spread.get(now); + dir_pop += pop_sp * 10; - dout(20) << "hit_dir " << type << " pop " << dir_pop << " in " << *dir << dendl; + if (pop_sp > 0) + dout(20) << "hit_dir " << type << " pop " << dir_pop << " spread " << pop_sp << " in " << *dir << dendl; if (dir->is_auth()) { if (!dir->is_rep() && diff --git a/trunk/ceph/mds/MDBalancer.h b/trunk/ceph/mds/MDBalancer.h index 5dd4f17940c60..819c69f0616c0 100644 --- a/trunk/ceph/mds/MDBalancer.h +++ b/trunk/ceph/mds/MDBalancer.h @@ -103,8 +103,8 @@ class MDBalancer { void subtract_export(class CDir *ex); void add_import(class CDir *im); - void hit_inode(utime_t now, class CInode *in, int type); - void hit_dir(utime_t now, class CDir *dir, int type, double amount=1.0); + void hit_inode(utime_t now, class CInode *in, int type, int who=-1); + void hit_dir(utime_t now, class CDir *dir, int type, int who, double amount=1.0); void hit_recursive(utime_t now, class CDir *dir, int type, double amount, double rd_adj); diff --git a/trunk/ceph/mds/Server.cc b/trunk/ceph/mds/Server.cc index e48c8a52e94a6..2fc1e272f6de2 100644 --- a/trunk/ceph/mds/Server.cc +++ b/trunk/ceph/mds/Server.cc @@ -1591,7 +1591,7 @@ void Server::handle_client_readdir(MDRequest *mdr) reply->set_result(0); // bump popularity. NOTE: this doesn't quite capture it. - mds->balancer->hit_dir(g_clock.now(), dir, META_POP_IRD, numfiles); + mds->balancer->hit_dir(g_clock.now(), dir, META_POP_IRD, mdr->client_request->get_source().num(), numfiles); // reply reply_request(mdr, reply, diri); @@ -3555,7 +3555,7 @@ void Server::_do_open(MDRequest *mdr, CInode *cur) cmode == FILE_MODE_W) mds->balancer->hit_inode(mdr->now, cur, META_POP_IWR); else - mds->balancer->hit_inode(mdr->now, cur, META_POP_IRD); + mds->balancer->hit_inode(mdr->now, cur, META_POP_IRD, mdr->client_request->get_source().num()); // reply MClientReply *reply = new MClientReply(req, 0); diff --git a/trunk/ceph/mds/mdstypes.h b/trunk/ceph/mds/mdstypes.h index 4798ad6fbcc48..fd46055a668cf 100644 --- a/trunk/ceph/mds/mdstypes.h +++ b/trunk/ceph/mds/mdstypes.h @@ -276,6 +276,36 @@ inline mds_load_t operator/( mds_load_t& a, double d ) */ +class load_spread_t { + static const int MAX = 4; + int last[MAX]; + int p, n; + DecayCounter count; + +public: + load_spread_t() : p(0), n(0) { + for (int i=0; i