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)
{
ceph::coarse_mono_time last_popularity_sample = ceph::coarse_mono_clock::zero();
- load_spread_t pop_spread;
-
elist<CInode*> pop_lru_subdirs;
std::unique_ptr<bloom_filter> bloom; // XXX not part of mempool::mds_co
}
}
-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)
}
}
-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;
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;
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);
// 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;
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()) {
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;
<< ">";
}
-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<n; i++)
- if (last[i] == who)
- return count.get_last();
-
- // we're new(ish)
- last[p++] = who;
- if (n < MAX) n++;
- if (n == 1) return 0.0;
-
- if (p == MAX) p = 0;
-
- return count.hit();
- }
- double get() const {
- return count.get();
- }
-
- std::array<int, MAX> last = {-1, -1, -1, -1};
- int p = 0, n = 0;
- DecayCounter count;
-};
-
// ================================================================
typedef std::pair<mds_rank_t, mds_rank_t> mds_authority_t;