From: Yan, Zheng Date: Thu, 20 Feb 2014 02:54:45 +0000 (+0800) Subject: mds: fix stack overflow caused by nested dispatch X-Git-Tag: v0.79~111^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc3325b37be49f1b7a30aa85645bc1d13fc3ed15;p=ceph.git mds: fix stack overflow caused by nested dispatch Signed-off-by: Yan, Zheng --- diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index c62b75fc190..60b28d4a932 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -136,6 +136,8 @@ MDS::MDS(const std::string &n, Messenger *m, MonClient *mc) : server = new Server(this); locker = new Locker(this, mdcache); + dispatch_depth = 0; + // clients last_client_mdsmap_bcast = 0; @@ -1711,7 +1713,9 @@ bool MDS::ms_dispatch(Message *m) m->put(); ret = true; } else { + inc_dispatch_depth(); ret = _dispatch(m); + dec_dispatch_depth(); } mds_lock.Unlock(); return ret; @@ -1930,6 +1934,9 @@ bool MDS::_dispatch(Message *m) } } + if (dispatch_depth > 1) + return true; + while (!waiting_for_nolaggy.empty()) { // stop if we're laggy now! diff --git a/src/mds/MDS.h b/src/mds/MDS.h index ac68fea83f3..b84f8a8ac65 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -321,6 +321,7 @@ class MDS : public Dispatcher { } private: + int dispatch_depth; bool ms_dispatch(Message *m); bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new); bool ms_verify_authorizer(Connection *con, int peer_type, @@ -409,6 +410,9 @@ class MDS : public Dispatcher { void request_osdmap(Context *c); + void inc_dispatch_depth() { ++dispatch_depth; } + void dec_dispatch_depth() { --dispatch_depth; } + // messages bool _dispatch(Message *m); @@ -436,7 +440,9 @@ public: this->mds = mds; } virtual void finish(int r) { + mds->inc_dispatch_depth(); mds->_dispatch(m); + mds->dec_dispatch_depth(); } };