From 964d966969bf757570bffb650ebb4ef515a6592e Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 30 Aug 2017 16:19:36 -0400 Subject: [PATCH] rgw: introduce RGWRadosNotifyCR for aio_notify Signed-off-by: Casey Bodley --- src/rgw/rgw_cr_rados.cc | 33 +++++++++++++++++++++++++++++++++ src/rgw/rgw_cr_rados.h | 19 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index fabf387e70f..002220f2e42 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -794,3 +794,36 @@ int RGWStatObjCR::request_complete() { return req->get_ret_status(); } + +RGWRadosNotifyCR::RGWRadosNotifyCR(RGWRados *store, const rgw_raw_obj& obj, + bufferlist& request, uint64_t timeout_ms, + bufferlist *response) + : RGWSimpleCoroutine(store->ctx()), store(store), obj(obj), + request(request), timeout_ms(timeout_ms), response(response) +{ + set_description() << "notify dest=" << obj; +} + +int RGWRadosNotifyCR::send_request() +{ + int r = store->get_raw_obj_ref(obj, &ref); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; + return r; + } + + set_status() << "sending request"; + + cn = stack->create_completion_notifier(); + return ref.ioctx.aio_notify(ref.oid, cn->completion(), request, + timeout_ms, response); +} + +int RGWRadosNotifyCR::request_complete() +{ + int r = cn->completion()->get_return_value(); + + set_status() << "request complete; ret=" << r; + + return r; +} diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index a82bb35b5fc..144ffbc0bf2 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -1154,4 +1154,23 @@ class RGWStatObjCR : public RGWSimpleCoroutine { int request_complete() override; }; +/// coroutine wrapper for IoCtx::aio_notify() +class RGWRadosNotifyCR : public RGWSimpleCoroutine { + RGWRados *const store; + const rgw_raw_obj obj; + bufferlist request; + const uint64_t timeout_ms; + bufferlist *response; + rgw_rados_ref ref; + boost::intrusive_ptr cn; + +public: + RGWRadosNotifyCR(RGWRados *store, const rgw_raw_obj& obj, + bufferlist& request, uint64_t timeout_ms, + bufferlist *response); + + int send_request() override; + int request_complete() override; +}; + #endif -- 2.39.5