From: Yehuda Sadeh Date: Fri, 29 Sep 2017 21:34:05 +0000 (-0700) Subject: rgw: rest cr drains writes, returns errors X-Git-Tag: v13.1.0~270^2~90 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e1e07bbae57921b348571a5741a298d5a6132fdc;p=ceph.git rgw: rest cr drains writes, returns errors Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_cr_rest.cc b/src/rgw/rgw_cr_rest.cc index 4ef73192cd05..116857f520c9 100644 --- a/src/rgw/rgw_cr_rest.cc +++ b/src/rgw/rgw_cr_rest.cc @@ -103,6 +103,21 @@ int RGWStreamRWHTTPResourceCRF::write(bufferlist& data) return 0; } +int RGWStreamRWHTTPResourceCRF::drain_writes(bool *need_retry) +{ + reenter(&drain_state) { + *need_retry = true; + yield req->finish_write(); + *need_retry = !req->is_done(); + while (!req->is_done()) { + yield caller->io_block(0, req->get_io_id()); + *need_retry = !req->is_done(); + } + return req->get_req_retcode(); + } + return 0; +} + TestCR::TestCR(CephContext *_cct, RGWHTTPManager *_mgr, RGWHTTPStreamRWRequest *_req) : RGWCoroutine(_cct), cct(_cct), http_manager(_mgr), req(_req) {} TestCR::~TestCR() { @@ -134,7 +149,6 @@ int TestCR::operate() { } while (need_retry); if (retcode < 0) { - dout(0) << __FILE__ << ":" << __LINE__ << " retcode=" << retcode << dendl; return set_cr_error(ret); } @@ -152,13 +166,21 @@ int TestCR::operate() { } if (retcode < 0) { - dout(0) << __FILE__ << ":" << __LINE__ << " retcode=" << retcode << dendl; return set_cr_error(ret); } dout(0) << "wrote " << bl.length() << " bytes" << dendl; } while (true); + do { + yield { + int ret = crf->drain_writes(&need_retry); + if (ret < 0) { + return set_cr_error(ret); + } + } + } while (need_retry); + return set_cr_done(); } return 0; @@ -205,7 +227,7 @@ int TestSpliceCR::operate() { } if (retcode < 0) { - dout(0) << __FILE__ << ":" << __LINE__ << " retcode=" << retcode << dendl; + ldout(20) << __func__ << ": in_crf->read() retcode=" << retcode << dendl; return set_cr_error(ret); } } while (need_retry); @@ -224,13 +246,22 @@ int TestSpliceCR::operate() { } if (retcode < 0) { - dout(0) << __FILE__ << ":" << __LINE__ << " retcode=" << retcode << dendl; + ldout(20) << __func__ << ": out_crf->write() retcode=" << retcode << dendl; return set_cr_error(ret); } dout(0) << "wrote " << bl.length() << " bytes" << dendl; } while (true); + do { + yield { + int ret = out_crf->drain_writes(&need_retry); + if (ret < 0) { + return set_cr_error(ret); + } + } + } while (need_retry); + return set_cr_done(); } return 0; diff --git a/src/rgw/rgw_cr_rest.h b/src/rgw/rgw_cr_rest.h index 01ac7a7e2168..be50387039c4 100644 --- a/src/rgw/rgw_cr_rest.h +++ b/src/rgw/rgw_cr_rest.h @@ -319,6 +319,7 @@ class RGWStreamRWHTTPResourceCRF { boost::asio::coroutine read_state; boost::asio::coroutine write_state; + boost::asio::coroutine drain_state; public: @@ -335,6 +336,7 @@ public: int init(); int read(bufferlist *data, uint64_t max, bool *need_retry); /* reentrant */ int write(bufferlist& data); /* reentrant */ + int drain_writes(bool *need_retry); /* reentrant */ }; class TestCR : public RGWCoroutine {