From: Yan, Zheng Date: Wed, 19 Oct 2016 12:42:25 +0000 (+0800) Subject: mds: avoid wrapping C_IO_Wrapper with C_OnFinisher X-Git-Tag: v11.1.0~522^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42b7790a59458187e84fae03d66ecacc64f942dd;p=ceph.git mds: avoid wrapping C_IO_Wrapper with C_OnFinisher Signed-off-by: Yan, Zheng --- diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index de7806dea700..77d1269bfff6 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -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(); diff --git a/src/mds/MDSContext.cc b/src/mds/MDSContext.cc index d1c32761476f..493e97bb4204 100644 --- a/src/mds/MDSContext.cc +++ b/src/mds/MDSContext.cc @@ -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; diff --git a/src/mds/MDSContext.h b/src/mds/MDSContext.h index a69223dc7b3e..57ab7d0660de 100644 --- a/src/mds/MDSContext.h +++ b/src/mds/MDSContext.h @@ -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; - } }; diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 33af04e36cd7..42b0e588fb27 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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) { diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 7caee1260b53..3a7b88778d4c 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -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; } }