From: Adam C. Emerson Date: Mon, 23 Nov 2020 20:29:35 +0000 (-0500) Subject: rgw: Add rgw_complete_aio_completion() X-Git-Tag: v17.1.0~2399^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97c3f2b4e6d0a8d0c2366d6dca4570e063af7953;p=ceph.git rgw: Add rgw_complete_aio_completion() To manually complete an asynchronous librados call. Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/cls_fifo_legacy.cc b/src/rgw/cls_fifo_legacy.cc index 569a3e77c458..f95b796152d3 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 ae5cf9ae3d96..d2c985b29dbf 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 43a618c4a4a7..d175d86c8fb8 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" @@ -591,3 +593,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 d2c08284d8ed..d08a41ac9a26 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