]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rest cr drains writes, returns errors
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 29 Sep 2017 21:34:05 +0000 (14:34 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:38 +0000 (08:05 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_rest.cc
src/rgw/rgw_cr_rest.h

index 4ef73192cd0554abf218b9c8f228c03946349bcd..116857f520c98d2c2a94f1383b7cf85962ab57b3 100644 (file)
@@ -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;
index 01ac7a7e216805722e5c0577882cf2f6159a1b31..be50387039c4de3053616aacabf9636fc24d5f8e 100644 (file)
@@ -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 {