From: Adam C. Emerson Date: Mon, 23 Nov 2020 20:29:35 +0000 (-0500) Subject: rgw: Add rgw_complete_aio_completion() X-Git-Tag: v16.2.2~8^2~9^2~16 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=739be4ff5322878d80a593f9364295c2ed1c1b86;p=ceph.git rgw: Add rgw_complete_aio_completion() To manually complete an asynchronous librados call. Signed-off-by: Adam C. Emerson (cherry picked from commit 97c3f2b4e6d0a8d0c2366d6dca4570e063af7953) Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/cls_fifo_legacy.cc b/src/rgw/cls_fifo_legacy.cc index 569a3e77c458f..f95b796152d33 100644 --- a/src/rgw/cls_fifo_legacy.cc +++ b/src/rgw/cls_fifo_legacy.cc @@ -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) { diff --git a/src/rgw/rgw_datalog.cc b/src/rgw/rgw_datalog.cc index 329657d463125..460ebd105dca8 100644 --- a/src/rgw/rgw_datalog.cc +++ b/src/rgw/rgw_datalog.cc @@ -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); } diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 89a322b0675ad..82e0ecf546d60 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -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); +} diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index 28d251c28d6c6..cf586dabea9cf 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -253,4 +253,9 @@ public: using RGWDataAccessRef = std::shared_ptr; +/// 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