From: Yan, Zheng Date: Thu, 23 Jan 2014 05:03:10 +0000 (+0800) Subject: mds: remove discover ino X-Git-Tag: v0.81~100^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1121%2Fhead;p=ceph.git mds: remove discover ino Anchor table was the main user of MDCache::discover_ino(), it has been removed. MDCache::discover_path() can replace discover_ino() in remaining places. This patch removes discover ino related code. Signed-off-by: Yan, Zheng --- diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index f3ae93e3657d..64d93c56c009 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1105,27 +1105,6 @@ void CDir::take_dentry_waiting(const string& dname, snapid_t first, snapid_t las put(PIN_DNWAITER); } -void CDir::add_ino_waiter(inodeno_t ino, Context *c) -{ - if (waiting_on_ino.empty()) - get(PIN_INOWAITER); - waiting_on_ino[ino].push_back(c); - dout(10) << "add_ino_waiter ino " << ino << " " << c << " on " << *this << dendl; -} - -void CDir::take_ino_waiting(inodeno_t ino, list& ls) -{ - if (waiting_on_ino.empty()) return; - if (waiting_on_ino.count(ino) == 0) return; - dout(10) << "take_ino_waiting ino " << ino - << " x " << waiting_on_ino[ino].size() - << " on " << *this << dendl; - ls.splice(ls.end(), waiting_on_ino[ino]); - waiting_on_ino.erase(ino); - if (waiting_on_ino.empty()) - put(PIN_INOWAITER); -} - void CDir::take_sub_waiting(list& ls) { dout(10) << "take_sub_waiting" << dendl; @@ -1137,14 +1116,6 @@ void CDir::take_sub_waiting(list& ls) waiting_on_dentry.clear(); put(PIN_DNWAITER); } - if (!waiting_on_ino.empty()) { - for (map >::iterator p = waiting_on_ino.begin(); - p != waiting_on_ino.end(); - ++p) - ls.splice(ls.end(), p->second); - waiting_on_ino.clear(); - put(PIN_INOWAITER); - } } diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 32071ea341b3..22a9d4c4bdef 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -531,7 +531,6 @@ public: // -- waiters -- protected: map< string_snap_t, list > waiting_on_dentry; - map< inodeno_t, list > waiting_on_ino; public: bool is_waiting_for_dentry(const string& dname, snapid_t snap) { @@ -539,13 +538,6 @@ public: } void add_dentry_waiter(const string& dentry, snapid_t snap, Context *c); void take_dentry_waiting(const string& dentry, snapid_t first, snapid_t last, list& ls); - - bool is_waiting_for_ino(inodeno_t ino) { - return waiting_on_ino.count(ino); - } - void add_ino_waiter(inodeno_t ino, Context *c); - void take_ino_waiting(inodeno_t ino, list& ls); - void take_sub_waiting(list& ls); // dentry or ino void add_waiter(uint64_t mask, Context *c); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 66989ddcdffc..e74bd4424254 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -9519,8 +9519,8 @@ void MDCache::migrate_stray(CDentry *dn, int to) void MDCache::_send_discover(discover_info_t& d) { - MDiscover *dis = new MDiscover(d.ino, d.frag, d.snap, - d.want_path, d.want_ino, d.want_base_dir, d.want_xlocked); + MDiscover *dis = new MDiscover(d.ino, d.frag, d.snap, d.want_path, + d.want_base_dir, d.want_xlocked); dis->set_tid(d.tid); mds->send_message_mds(dis, d.mds); } @@ -9675,58 +9675,6 @@ void MDCache::discover_path(CDir *base, base->add_dentry_waiter(want_path[0], snap, onfinish); } -struct C_MDC_RetryDiscoverIno : public Context { - MDCache *mdc; - CDir *base; - inodeno_t want_ino; - C_MDC_RetryDiscoverIno(MDCache *c, CDir *b, inodeno_t i) : - mdc(c), base(b), want_ino(i) {} - void finish(int r) { - mdc->discover_ino(base, want_ino, 0); - } -}; - -void MDCache::discover_ino(CDir *base, - inodeno_t want_ino, - Context *onfinish, - bool want_xlocked) -{ - int from = base->authority().first; - - dout(7) << "discover_ino " << base->dirfrag() << " " << want_ino << " from mds." << from - << (want_xlocked ? " want_xlocked":"") - << dendl; - - if (base->is_ambiguous_auth()) { - dout(10) << " waiting for single auth on " << *base << dendl; - if (!onfinish) - onfinish = new C_MDC_RetryDiscoverIno(this, base, want_ino); - base->add_waiter(CDir::WAIT_SINGLEAUTH, onfinish); - return; - } else if (from == mds->get_nodeid()) { - list finished; - base->take_sub_waiting(finished); - mds->queue_waiters(finished); - return; - } - - if (want_xlocked || !base->is_waiting_for_ino(want_ino) || !onfinish) { - discover_info_t& d = _create_discover(from); - d.ino = base->ino(); - d.frag = base->get_frag(); - d.want_ino = want_ino; - d.want_base_dir = false; - d.want_xlocked = want_xlocked; - _send_discover(d); - } - - // register + wait - if (onfinish) - base->add_ino_waiter(want_ino, onfinish); -} - - - void MDCache::kick_discovers(int who) { for (map::iterator p = discovers.begin(); @@ -9835,7 +9783,7 @@ void MDCache::handle_discover(MDiscover *dis) fg = cur->pick_dirfrag(dis->get_dentry(i)); } else { // requester explicity specified the frag - assert(dis->wants_base_dir() || dis->get_want_ino() || MDS_INO_IS_BASE(dis->get_base_ino())); + assert(dis->wants_base_dir() || MDS_INO_IS_BASE(dis->get_base_ino())); fg = dis->get_base_dir_frag(); if (!cur->dirfragtree.is_leaf(fg)) fg = cur->dirfragtree[fg.value()]; @@ -9925,18 +9873,6 @@ void MDCache::handle_discover(MDiscover *dis) CDentry *dn = 0; if (curdir->get_version() == 0) { // fetch newly opened dir - } else if (dis->get_want_ino()) { - // lookup by ino - CInode *in = get_inode(dis->get_want_ino(), snapid); - if (in && in->is_auth() && in->get_parent_dn()->get_dir() == curdir) { - dn = in->get_parent_dn(); - if (dn->state_test(CDentry::STATE_PURGING)) { - // set error flag in reply - dout(7) << "dentry " << *dn << " is purging, flagging error ino" << dendl; - reply->set_flag_error_ino(); - break; - } - } } else if (dis->get_want().depth() > 0) { // lookup dentry dn = curdir->lookup(dis->get_dentry(i), snapid); @@ -9960,15 +9896,6 @@ void MDCache::handle_discover(MDiscover *dis) break; } } - - // don't have wanted ino in this dir? - if (dis->get_want_ino()) { - // set error flag in reply - dout(7) << "no ino " << dis->get_want_ino() << " in this dir, flagging error in " - << *curdir << dendl; - reply->set_flag_error_ino(); - break; - } // send null dentry dout(7) << "dentry " << dis->get_dentry(i) << " dne, returning null in " @@ -10056,8 +9983,6 @@ void MDCache::handle_discover_reply(MDiscoverReply *m) dout(7) << " flag error, dir" << dendl; if (m->is_flag_error_dn()) dout(7) << " flag error, dentry = " << m->get_error_dentry() << dendl; - if (m->is_flag_error_ino()) - dout(7) << " flag error, ino = " << m->get_wanted_ino() << dendl; list finished, error; int from = m->get_source().num(); @@ -10079,19 +10004,6 @@ void MDCache::handle_discover_reply(MDiscoverReply *m) } } - // discover ino error - if (p.end() && m->is_flag_error_ino()) { - assert(cur); - assert(cur->is_dir()); - CDir *dir = cur->get_dirfrag(m->get_base_dir_frag()); - if (dir) { - dout(7) << " flag_error on ino " << m->get_wanted_ino() - << ", triggering ino" << dendl; - dir->take_ino_waiting(m->get_wanted_ino(), error); - } else - assert(0); - } - // discover may start with an inode if (!p.end() && next == MDiscoverReply::INODE) { cur = add_replica_inode(p, NULL, finished); @@ -10186,14 +10098,6 @@ void MDCache::handle_discover_reply(MDiscoverReply *m) } else dout(7) << " doing nothing, have dir but nobody is waiting on dentry " << m->get_error_dentry() << dendl; - } else { - if (dir && m->get_wanted_ino() && dir->is_waiting_for_ino(m->get_wanted_ino())) { - if (dir->is_auth() || get_inode(m->get_wanted_ino())) - dir->take_ino_waiting(m->get_wanted_ino(), finished); - else - discover_ino(dir, m->get_wanted_ino(), 0, m->get_wanted_xlocked()); - } else - dout(7) << " doing nothing, nobody is waiting for ino" << dendl; } } @@ -10319,8 +10223,6 @@ CInode *MDCache::add_replica_inode(bufferlist::iterator& p, CDentry *dn, listget_linkage()->is_primary() || dn->get_linkage()->get_inode() != in) dout(10) << "add_replica_inode different linkage in dentry " << *dn << dendl; - - dn->get_dir()->take_ino_waiting(in->ino(), finished); } return in; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index bcfd63c72ff6..ff23e46e3ca7 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -137,7 +137,6 @@ public: frag_t frag; snapid_t snap; filepath want_path; - inodeno_t want_ino; bool want_base_dir; bool want_xlocked; @@ -166,9 +165,6 @@ public: bool want_xlocked=false, int from=-1); void discover_path(CDir *base, snapid_t snap, filepath want_path, Context *onfinish, bool want_xlocked=false); - void discover_ino(CDir *base, inodeno_t want_ino, Context *onfinish, - bool want_xlocked=false); - void kick_discovers(int who); // after a failure. diff --git a/src/messages/MDiscover.h b/src/messages/MDiscover.h index 296825ccc8b9..c37565dbef53 100644 --- a/src/messages/MDiscover.h +++ b/src/messages/MDiscover.h @@ -30,7 +30,6 @@ class MDiscover : public Message { snapid_t snapid; filepath want; // ... [/]need/this/stuff - inodeno_t want_ino; bool want_base_dir; bool want_xlocked; @@ -41,7 +40,6 @@ class MDiscover : public Message { snapid_t get_snapid() { return snapid; } filepath& get_want() { return want; } - inodeno_t get_want_ino() { return want_ino; } const string& get_dentry(int n) { return want[n]; } bool wants_base_dir() { return want_base_dir; } @@ -54,7 +52,6 @@ class MDiscover : public Message { frag_t base_frag_, snapid_t s, filepath& want_path_, - inodeno_t want_ino_, bool want_base_dir_ = true, bool discover_xlocks_ = false) : Message(MSG_MDS_DISCOVER), @@ -62,7 +59,6 @@ class MDiscover : public Message { base_dir_frag(base_frag_), snapid(s), want(want_path_), - want_ino(want_ino_), want_base_dir(want_base_dir_), want_xlocked(discover_xlocks_) { } private: @@ -72,10 +68,7 @@ public: const char *get_type_name() const { return "Dis"; } void print(ostream &out) const { out << "discover(" << header.tid << " " << base_ino << "." << base_dir_frag - << " " << want; - if (want_ino) - out << want_ino; - out << ")"; + << " " << want << ")"; } void decode_payload() { @@ -84,7 +77,6 @@ public: ::decode(base_dir_frag, p); ::decode(snapid, p); ::decode(want, p); - ::decode(want_ino, p); ::decode(want_base_dir, p); ::decode(want_xlocked, p); } @@ -93,7 +85,6 @@ public: ::encode(base_dir_frag, payload); ::encode(snapid, payload); ::encode(want, payload); - ::encode(want_ino, payload); ::encode(want_base_dir, payload); ::encode(want_xlocked, payload); } diff --git a/src/messages/MDiscoverReply.h b/src/messages/MDiscoverReply.h index 361a517b2e86..a28321ac4c5b 100644 --- a/src/messages/MDiscoverReply.h +++ b/src/messages/MDiscoverReply.h @@ -74,12 +74,10 @@ class MDiscoverReply : public Message { frag_t base_dir_frag; bool wanted_base_dir; bool wanted_xlocked; - inodeno_t wanted_ino; snapid_t wanted_snapid; // and the response bool flag_error_dn; - bool flag_error_ino; bool flag_error_dir; string error_dentry; // dentry that was not found (to trigger waiters on asker) bool unsolicited; @@ -97,11 +95,9 @@ class MDiscoverReply : public Message { frag_t get_base_dir_frag() { return base_dir_frag; } bool get_wanted_base_dir() { return wanted_base_dir; } bool get_wanted_xlocked() { return wanted_xlocked; } - inodeno_t get_wanted_ino() { return wanted_ino; } snapid_t get_wanted_snapid() { return wanted_snapid; } bool is_flag_error_dn() { return flag_error_dn; } - bool is_flag_error_ino() { return flag_error_ino; } bool is_flag_error_dir() { return flag_error_dir; } string& get_error_dentry() { return error_dentry; } @@ -122,10 +118,8 @@ class MDiscoverReply : public Message { base_dir_frag(dis->get_base_dir_frag()), wanted_base_dir(dis->wants_base_dir()), wanted_xlocked(dis->wants_xlocked()), - wanted_ino(dis->get_want_ino()), wanted_snapid(dis->get_snapid()), flag_error_dn(false), - flag_error_ino(false), flag_error_dir(false), unsolicited(false), dir_auth_hint(CDIR_AUTH_UNKNOWN), @@ -139,10 +133,8 @@ class MDiscoverReply : public Message { base_dir_frag(df.frag), wanted_base_dir(false), wanted_xlocked(false), - wanted_ino(inodeno_t()), wanted_snapid(CEPH_NOSNAP), flag_error_dn(false), - flag_error_ino(false), flag_error_dir(false), unsolicited(false), dir_auth_hint(CDIR_AUTH_UNKNOWN), @@ -163,7 +155,6 @@ public: bool is_empty() { return trace.length() == 0 && !flag_error_dn && - !flag_error_ino && !flag_error_dir && dir_auth_hint == CDIR_AUTH_UNKNOWN; } @@ -173,9 +164,6 @@ public: flag_error_dn = true; error_dentry = dn; } - void set_flag_error_ino() { - flag_error_ino = true; - } void set_flag_error_dir() { flag_error_dir = true; } @@ -196,7 +184,6 @@ public: ::decode(wanted_xlocked, p); ::decode(wanted_snapid, p); ::decode(flag_error_dn, p); - ::decode(flag_error_ino, p); ::decode(flag_error_dir, p); ::decode(error_dentry, p); ::decode(dir_auth_hint, p); @@ -204,8 +191,6 @@ public: ::decode(starts_with, p); ::decode(trace, p); - if (header.version >= 2) - ::decode(wanted_ino, p); } void encode_payload(uint64_t features) { ::encode(base_ino, payload); @@ -214,7 +199,6 @@ public: ::encode(wanted_xlocked, payload); ::encode(wanted_snapid, payload); ::encode(flag_error_dn, payload); - ::encode(flag_error_ino, payload); ::encode(flag_error_dir, payload); ::encode(error_dentry, payload); ::encode(dir_auth_hint, payload); @@ -222,9 +206,7 @@ public: ::encode(starts_with, payload); ::encode(trace, payload); - ::encode(wanted_ino, payload); } - }; #endif