From eb8b1578fe57d88c95177eda6b301a9becf46f47 Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 8 Oct 2007 23:46:55 +0000 Subject: [PATCH] client bits for DirStat git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1894 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/client/Client.cc | 28 +++++++++++++--------------- branches/sage/mds/client/Client.h | 13 ++++++++----- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/branches/sage/mds/client/Client.cc b/branches/sage/mds/client/Client.cc index b4bd9a5bffc05..0aa111e3f52db 100644 --- a/branches/sage/mds/client/Client.cc +++ b/branches/sage/mds/client/Client.cc @@ -409,25 +409,19 @@ Inode* Client::insert_inode(Dir *dir, InodeStat *st, const string& dname) * * update MDS location cache for a single inode */ -void Client::update_inode_dist(Inode *in, InodeStat *st) +void Client::update_dir_dist(Inode *in, DirStat *dst) { // auth in->dir_auth = -1; - if (st->dirfrag_auth.size() == 1) { - in->dir_auth = st->dirfrag_auth.begin()->second; + if (dst->frag == frag_t()) { + in->dir_auth = dst->auth; } else { - for (map::iterator p = st->dirfrag_auth.begin(); - p != st->dirfrag_auth.end(); - ++p) { - dout(20) << "got dirfrag map for " << in->inode.ino << " frag " << p->first << " to mds " << p->second << dendl; - in->fragmap[p->first] = p->second; - } + dout(20) << "got dirfrag map for " << in->inode.ino << " frag " << dst->frag << " to mds " << dst->auth << dendl; + in->fragmap[dst->frag] = dst->auth; } // replicated - in->dir_replicated = false; - if (!st->dirfrag_rep.empty()) - in->dir_replicated = true; // FIXME + in->dir_replicated = dst->is_rep; // FIXME that's just one frag! // dist /* @@ -457,6 +451,7 @@ Inode* Client::insert_trace(MClientReply *reply) dout(10) << "insert_trace got " << reply->get_trace_in().size() << " inodes" << dendl; list::const_iterator pdn = reply->get_trace_dn().begin(); + list::const_iterator pdir = reply->get_trace_dir().begin(); for (list::const_iterator pin = reply->get_trace_in().begin(); pin != reply->get_trace_in().end(); @@ -470,6 +465,7 @@ Inode* Client::insert_trace(MClientReply *reply) cur = root = new Inode((*pin)->inode, objectcacher); dout(10) << "insert_trace new root is " << root << dendl; inode_map[root->inode.ino] = root; + root->dir_auth = 0; } } else { // not root. @@ -483,14 +479,16 @@ Inode* Client::insert_trace(MClientReply *reply) lru.lru_touch(cur->dn); } - // update dist info - update_inode_dist(cur, *pin); - // set cache ttl if (g_conf.client_cache_stat_ttl) { cur->valid_until = now; cur->valid_until += g_conf.client_cache_stat_ttl; } + + // update dir dist info + if (pdir == reply->get_trace_dir().end()) break; + update_dir_dist(cur, *pdir); + ++pdir; } return cur; diff --git a/branches/sage/mds/client/Client.h b/branches/sage/mds/client/Client.h index 69da16b6e84d5..727098906c617 100644 --- a/branches/sage/mds/client/Client.h +++ b/branches/sage/mds/client/Client.h @@ -252,10 +252,13 @@ class Inode { if (!dirfragtree.empty()) { __gnu_cxx::hash H; frag_t fg = dirfragtree[H(dname)]; - if (fragmap.count(fg) && - fragmap[fg] >= 0) { - //cout << "picked frag ino " << inode.ino << " dname " << dname << " fg " << fg << " mds" << fragmap[fg] << std::endl; - return fragmap[fg]; + while (fg != frag_t()) { + if (fragmap.count(fg) && + fragmap[fg] >= 0) { + //cout << "picked frag ino " << inode.ino << " dname " << dname << " fg " << fg << " mds" << fragmap[fg] << std::endl; + return fragmap[fg]; + } + fg = frag_t(fg.value(), fg.bits()-1); // try more general... } } return authority(); @@ -682,7 +685,7 @@ protected: // metadata cache Inode* insert_inode(Dir *dir, InodeStat *in_info, const string& dn); - void update_inode_dist(Inode *in, InodeStat *st); + void update_dir_dist(Inode *in, DirStat *st); Inode* insert_trace(MClientReply *reply); // ---------------------- -- 2.39.5