]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Add rgw_complete_aio_completion()
authorAdam C. Emerson <aemerson@redhat.com>
Mon, 23 Nov 2020 20:29:35 +0000 (15:29 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 5 Apr 2021 17:42:37 +0000 (13:42 -0400)
To manually complete an asynchronous librados call.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
(cherry picked from commit 97c3f2b4e6d0a8d0c2366d6dca4570e063af7953)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/cls_fifo_legacy.cc
src/rgw/rgw_datalog.cc
src/rgw/rgw_tools.cc
src/rgw/rgw_tools.h

index 569a3e77c458f770d85bb018e245e4abfecb2e22..f95b796152d3379f92f29bebf2be542382491a19 100644 (file)
@@ -428,28 +428,10 @@ public:
     return c;
   }
   static void complete(Ptr&& p, int r) {
-    auto c = p->_super->pc;
+    auto c = p->_super;
     p->_super = nullptr;
-    c->lock.lock();
-    c->rval = r;
-    c->complete = true;
-    c->lock.unlock();
-
-    auto cb_complete = c->callback_complete;
-    auto cb_complete_arg = c->callback_complete_arg;
-    if (cb_complete)
-      cb_complete(c, cb_complete_arg);
-
-    auto cb_safe = c->callback_safe;
-    auto cb_safe_arg = c->callback_safe_arg;
-    if (cb_safe)
-      cb_safe(c, cb_safe_arg);
-
-    c->lock.lock();
-    c->callback_complete = nullptr;
-    c->callback_safe = nullptr;
-    c->cond.notify_all();
-    c->put_unlock();
+    c->pc->put();
+    rgw_complete_aio_completion(c, r);
   }
 
   static void cb(lr::completion_t, void* arg) {
index 329657d463125b5ccbc80f2d2e40926c760f1816..460ebd105dca876cd4f775b1211173c443c2dce0 100644 (file)
@@ -333,27 +333,7 @@ public:
           librados::AioCompletion* c) override {
     int r = 0;
     if (marker == rgw::cls::fifo::marker(0, 0).to_string()) {
-      auto pc = c->pc;
-      pc->get();
-      pc->lock.lock();
-      pc->rval = 0;
-      pc->complete = true;
-      pc->lock.unlock();
-      auto cb_complete = pc->callback_complete;
-      auto cb_complete_arg = pc->callback_complete_arg;
-      if (cb_complete)
-       cb_complete(pc, cb_complete_arg);
-
-      auto cb_safe = pc->callback_safe;
-      auto cb_safe_arg = pc->callback_safe_arg;
-      if (cb_safe)
-       cb_safe(pc, cb_safe_arg);
-
-      pc->lock.lock();
-      pc->callback_complete = NULL;
-      pc->callback_safe = NULL;
-      pc->cond.notify_all();
-      pc->put_unlock();
+      rgw_complete_aio_completion(c, 0);
     } else {
       fifos[index]->trim(marker, false, c);
     }
index 89a322b0675ad8c154d36c89ec63c423669cc0e2..82e0ecf546d60127e5a505e2380fa76210c3718a 100644 (file)
@@ -11,6 +11,8 @@
 #include "include/types.h"
 #include "include/stringify.h"
 
+#include "librados/AioCompletionImpl.h"
+
 #include "rgw_common.h"
 #include "rgw_tools.h"
 #include "rgw_acl_s3.h"
@@ -592,3 +594,9 @@ void rgw_tools_cleanup()
   delete ext_mime_map;
   ext_mime_map = nullptr;
 }
+
+void rgw_complete_aio_completion(librados::AioCompletion* c, int r) {
+  auto pc = c->pc;
+  librados::CB_AioCompleteAndSafe cb(pc);
+  cb(r);
+}
index 28d251c28d6c69a0d24d235551551f0ab7679125..cf586dabea9cfb2b5cf6d1694c0b3fa07069c5c0 100644 (file)
@@ -253,4 +253,9 @@ public:
 
 using RGWDataAccessRef = std::shared_ptr<RGWDataAccess>;
 
+/// Complete an AioCompletion. To return error values or otherwise
+/// satisfy the caller. Useful for making complicated asynchronous
+/// calls and error handling.
+void rgw_complete_aio_completion(librados::AioCompletion* c, int r);
+
 #endif