From: Patrick Donnelly Date: Thu, 17 Feb 2022 20:03:52 +0000 (-0500) Subject: mds: remove CDir::pop_spread X-Git-Tag: v18.0.0~578^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=165fdc96e461ebc72b7ce0c516003fd81c653ff5;p=ceph.git mds: remove CDir::pop_spread This is a old artifact of when it was thought MDS requests would be forwarded. It seemed good to track popularity based on who sent the request. So, "who" is almost always -1. Because of this, a directory's CDir::pop_spread is never actually hit. This has the side-effect of preventing any replication except from hits from open/getattr! Instead of using pop_spread, just use CDir::pop_me. Also, replicate for any read load including READDIR. Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index f53e44e6f189..7744a47e4540 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -208,7 +208,6 @@ CDir::CDir(CInode *in, frag_t fg, MDCache *mdc, bool auth) : pop_nested(mdc->decayrate), pop_auth_subtree(mdc->decayrate), pop_auth_subtree_nested(mdc->decayrate), - pop_spread(mdc->decayrate), pop_lru_subdirs(member_offset(CInode, item_pop_lru)), dir_auth(CDIR_AUTH_DEFAULT) { diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 852f86ba826e..f6eb938638ed 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -738,8 +738,6 @@ protected: ceph::coarse_mono_time last_popularity_sample = ceph::coarse_mono_clock::zero(); - load_spread_t pop_spread; - elist pop_lru_subdirs; std::unique_ptr bloom; // XXX not part of mempool::mds_co diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 138f65fb5794..7eb7722b190f 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -1190,13 +1190,13 @@ void MDBalancer::find_exports(CDir *dir, } } -void MDBalancer::hit_inode(CInode *in, int type, int who) +void MDBalancer::hit_inode(CInode *in, int type) { // hit inode in->pop.get(type).hit(); if (in->get_parent_dn()) - hit_dir(in->get_parent_dn()->get_dir(), type, who); + hit_dir(in->get_parent_dn()->get_dir(), type); } void MDBalancer::maybe_fragment(CDir *dir, bool hot) @@ -1229,7 +1229,7 @@ void MDBalancer::maybe_fragment(CDir *dir, bool hot) } } -void MDBalancer::hit_dir(CDir *dir, int type, int who, double amount) +void MDBalancer::hit_dir(CDir *dir, int type, double amount) { if (dir->inode->is_stray()) return; @@ -1245,30 +1245,16 @@ void MDBalancer::hit_dir(CDir *dir, int type, int who, double amount) maybe_fragment(dir, hot); // replicate? - if (type == META_POP_IRD && who >= 0) { - dir->pop_spread.hit(who); - } - + const bool readop = (type == META_POP_IRD || type == META_POP_READDIR); double rd_adj = 0.0; - if (type == META_POP_IRD && - dir->last_popularity_sample < last_sample) { + if (readop && dir->last_popularity_sample < last_sample) { double dir_pop = dir->pop_auth_subtree.get(type).get(); // hmm?? + dir_pop += v * 10; dir->last_popularity_sample = last_sample; - double pop_sp = dir->pop_spread.get(); - dir_pop += pop_sp * 10; - - if (pop_sp > 0) { - dout(20) << type << " pop " << dir_pop << " spread " << pop_sp - << " " << dir->pop_spread.last[0] - << " " << dir->pop_spread.last[1] - << " " << dir->pop_spread.last[2] - << " " << dir->pop_spread.last[3] - << " in " << *dir << dendl; - } - if (dir->is_auth() && !dir->is_ambiguous_auth()) { - if (dir->can_rep() && - dir_pop >= g_conf()->mds_bal_replicate_threshold) { + dout(20) << type << " pop " << dir_pop << " spread in " << *dir << dendl; + if (dir->is_auth() && !dir->is_ambiguous_auth() && dir->can_rep()) { + if (dir_pop >= g_conf()->mds_bal_replicate_threshold) { // replicate double rdp = dir->pop_me.get(META_POP_IRD).get(); rd_adj = rdp / mds->get_mds_map()->get_num_in_mds() - rdp; diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index e3ee3deabcff..2f5cf730ec54 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -55,8 +55,8 @@ public: void add_import(CDir *im); void adjust_pop_for_rename(CDir *pdir, CDir *dir, bool inc); - void hit_inode(CInode *in, int type, int who=-1); - void hit_dir(CDir *dir, int type, int who=-1, double amount=1.0); + void hit_inode(CInode *in, int type); + void hit_dir(CDir *dir, int type, double amount=1.0); void queue_split(const CDir *dir, bool fast); void queue_merge(CDir *dir); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5ec4aabb6e4f..42d69e5faf21 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3988,7 +3988,7 @@ void Server::handle_client_getattr(MDRequestRef& mdr, bool is_lookup) // value for them. (currently this matters for xattrs and inline data) mdr->getattr_caps = mask; - mds->balancer->hit_inode(ref, META_POP_IRD, req->get_source().num()); + mds->balancer->hit_inode(ref, META_POP_IRD); // reply dout(10) << "reply to stat on " << *req << dendl; @@ -4387,8 +4387,7 @@ void Server::handle_client_open(MDRequestRef& mdr) if (cmode & CEPH_FILE_MODE_WR) mds->balancer->hit_inode(cur, META_POP_IWR); else - mds->balancer->hit_inode(cur, META_POP_IRD, - mdr->client_request->get_source().num()); + mds->balancer->hit_inode(cur, META_POP_IRD); CDentry *dn = 0; if (req->get_dentry_wanted()) { @@ -4871,7 +4870,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr) mdr->reply_extra_bl = dirbl; // bump popularity. NOTE: this doesn't quite capture it. - mds->balancer->hit_dir(dir, META_POP_READDIR, -1, numfiles); + mds->balancer->hit_dir(dir, META_POP_READDIR, numfiles); // reply mdr->tracei = diri; diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index fd53f39b71ba..70679e229a6d 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -1870,40 +1870,6 @@ inline std::ostream& operator<<(std::ostream& out, const mds_load_t& load) << ">"; } -class load_spread_t { -public: - using time = DecayCounter::time; - using clock = DecayCounter::clock; - static const int MAX = 4; - - load_spread_t(const DecayRate &rate) : count(rate) - {} - - load_spread_t() = delete; - - double hit(int who) { - for (int i=0; i last = {-1, -1, -1, -1}; - int p = 0, n = 0; - DecayCounter count; -}; - // ================================================================ typedef std::pair mds_authority_t;