]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix stack overflow caused by nested dispatch
authorYan, Zheng <zheng.z.yan@intel.com>
Thu, 20 Feb 2014 02:54:45 +0000 (10:54 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Wed, 19 Mar 2014 03:35:56 +0000 (11:35 +0800)
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/MDS.cc
src/mds/MDS.h

index c62b75fc190ee7330ac2cae6895f66ca5c6e5540..60b28d4a93297f03e6a7c6fa79a7071430e5e919 100644 (file)
@@ -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!
index ac68fea83f3a3c1ec4c463ed7a5a5850adec50d3..b84f8a8ac659cc673e380a8a4bd4efe87dacd3af 100644 (file)
@@ -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();
   }
 };