]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: avoid wrapping C_IO_Wrapper with C_OnFinisher
authorYan, Zheng <zyan@redhat.com>
Wed, 19 Oct 2016 12:42:25 +0000 (20:42 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 21 Oct 2016 06:40:49 +0000 (14:40 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/MDLog.cc
src/mds/MDSContext.cc
src/mds/MDSContext.h
src/mds/MDSRank.cc
src/mds/Server.cc

index de7806dea70003192ce2fb1d9d558a49c2c125ea..77d1269bfff61491a32323582248f742a3e98e86 100644 (file)
@@ -118,9 +118,9 @@ class C_MDL_WriteError : public MDSIOContextBase {
 
 void MDLog::write_head(MDSInternalContextBase *c) 
 {
-  C_OnFinisher *fin = NULL;
+  Context *fin = NULL;
   if (c != NULL) {
-    fin = new C_OnFinisher(new C_IO_Wrapper(mds, c), mds->finisher);
+    fin = new C_IO_Wrapper(mds, c);
   }
   journaler->write_head(fin);
 }
@@ -149,7 +149,7 @@ void MDLog::create(MDSInternalContextBase *c)
   C_GatherBuilder gather(g_ceph_context);
   // This requires an OnFinisher wrapper because Journaler will call back the completion for write_head inside its own lock
   // XXX but should maybe that be handled inside Journaler?
-  gather.set_finisher(new C_OnFinisher(new C_IO_Wrapper(mds, c), mds->finisher));
+  gather.set_finisher(new C_IO_Wrapper(mds, c));
 
   // The inode of the default Journaler we will create
   ino = MDS_INO_LOG_OFFSET + mds->get_nodeid();
index d1c32761476fc37fa597eb3ceb6c85740237f539..493e97bb4204c8cf1d66bcb323ce38af8d2baa42 100644 (file)
@@ -79,6 +79,16 @@ void MDSIOContextWrapper::finish(int r)
   fin->complete(r);
 }
 
+void C_IO_Wrapper::complete(int r)
+{
+  if (async) {
+    async = false;
+    get_mds()->finisher->queue(this, r);
+  } else {
+    MDSIOContext::complete(r);
+  }
+}
+
 MDSRank *MDSInternalContextGather::get_mds()
 {
   derr << "Forbidden call to MDSInternalContextGather::get_mds by " << typeid(*this).name() << dendl;
index a69223dc7b3eb7c4a464b5ac989dd10d65351c76..57ab7d0660defe1254e33a9951ea3c9d87d85f44 100644 (file)
@@ -77,7 +77,8 @@ public:
 
 class MDSIOContextBase : public MDSContext
 {
-    void complete(int r);
+public:
+  void complete(int r);
 };
 
 /**
@@ -129,10 +130,17 @@ public:
  */
 class C_IO_Wrapper : public MDSIOContext
 {
-private:
+protected:
+  bool async;
   MDSInternalContextBase *wrapped;
+  virtual void finish(int r) {
+    wrapped->complete(r);
+    wrapped = nullptr;
+  }
+  virtual void complete(int r) final;
 public:
-  C_IO_Wrapper(MDSRank *mds_, MDSInternalContextBase *wrapped_) : MDSIOContext(mds_), wrapped(wrapped_) {
+  C_IO_Wrapper(MDSRank *mds_, MDSInternalContextBase *wrapped_) :
+    MDSIOContext(mds_), async(true), wrapped(wrapped_) {
     assert(wrapped != NULL);
   }
 
@@ -142,11 +150,6 @@ public:
       wrapped = nullptr;
     }
   }
-
-  virtual void finish(int r) {
-    wrapped->complete(r);
-    wrapped = nullptr;
-  }
 };
 
 
index 33af04e36cd77bb305f5771a6ff8f0dd1ed8659d..42b0e588fb27452c29754245437937e474638063 100644 (file)
@@ -1029,7 +1029,7 @@ void MDSRank::replay_start()
   calc_recovery_set();
 
   // Check if we need to wait for a newer OSD map before starting
-  Context *fin = new C_OnFinisher(new C_IO_Wrapper(this, new C_MDS_BootStart(this, MDS_BOOT_INITIAL)), finisher);
+  Context *fin = new C_IO_Wrapper(this, new C_MDS_BootStart(this, MDS_BOOT_INITIAL));
   bool const ready = objecter->wait_for_map(
       mdsmap->get_last_failure_osd_epoch(),
       fin);
@@ -1079,9 +1079,7 @@ inline void MDSRank::standby_replay_restart()
     /* We are transitioning out of standby: wait for OSD map update
        before making final pass */
     dout(1) << "standby_replay_restart (final takeover pass)" << dendl;
-    Context *fin = new C_OnFinisher(new C_IO_Wrapper(this,
-          new C_MDS_BootStart(this, MDS_BOOT_PREPARE_LOG)),
-      finisher);
+    Context *fin = new C_IO_Wrapper(this, new C_MDS_BootStart(this, MDS_BOOT_PREPARE_LOG));
     bool const ready =
       objecter->wait_for_map(mdsmap->get_last_failure_osd_epoch(), fin);
     if (ready) {
index 7caee1260b5381733169fb7dba4863bca860068d..3a7b88778d4ce0d925052a54d47d977a7b114c61 100644 (file)
@@ -4218,8 +4218,7 @@ int Server::check_layout_vxattr(MDRequestRef& mdr,
     if (req_epoch > epoch) {
 
       // well, our map is older. consult mds.
-      Context *fin = new C_OnFinisher(new C_IO_Wrapper(mds,
-        new C_MDS_RetryRequest(mdcache, mdr)), mds->finisher);
+      Context *fin = new C_IO_Wrapper(mds, new C_MDS_RetryRequest(mdcache, mdr));
 
       if (!mds->objecter->wait_for_map(req_epoch, fin))
         return r; // wait, fin will retry this request later
@@ -4240,8 +4239,8 @@ int Server::check_layout_vxattr(MDRequestRef& mdr,
       // latest map. One day if COMPACT_VERSION of MClientRequest >=3,
       // we can remove those code.
       mdr->waited_for_osdmap = true;
-      mds->objecter->wait_for_latest_osdmap(new C_OnFinisher(new C_IO_Wrapper(
-        mds, new C_MDS_RetryRequest(mdcache, mdr)), mds->finisher));
+      mds->objecter->wait_for_latest_osdmap(new C_IO_Wrapper(
+                             mds, new C_MDS_RetryRequest(mdcache, mdr)));
       return r;
     }
   }