From 5a64703fd6d24399137aa550fec6023dec1be162 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 31 Mar 2020 09:22:51 -0400 Subject: [PATCH] rgw: add CR for omap_get_vals() Signed-off-by: Casey Bodley --- src/rgw/rgw_cr_rados.cc | 38 ++++++++++++++++++++++++++++++++++++++ src/rgw/rgw_cr_rados.h | 25 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index b1da90104cf..8d80a13391f 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -323,6 +323,44 @@ int RGWRadosGetOmapKeysCR::request_complete() return r; } +RGWRadosGetOmapValsCR::RGWRadosGetOmapValsCR(rgw::sal::RGWRadosStore *_store, + const rgw_raw_obj& _obj, + const string& _marker, + int _max_entries, + ResultPtr _result) + : RGWSimpleCoroutine(_store->ctx()), store(_store), obj(_obj), + marker(_marker), max_entries(_max_entries), + result(std::move(_result)) +{ + ceph_assert(result); // must be allocated + set_description() << "get omap keys dest=" << obj << " marker=" << marker; +} + +int RGWRadosGetOmapValsCR::send_request() { + int r = store->getRados()->get_raw_obj_ref(obj, &result->ref); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; + return r; + } + + set_status() << "send request"; + + librados::ObjectReadOperation op; + op.omap_get_vals2(marker, max_entries, &result->entries, &result->more, nullptr); + + cn = stack->create_completion_notifier(result); + return result->ref.pool.ioctx().aio_operate(result->ref.obj.oid, cn->completion(), &op, NULL); +} + +int RGWRadosGetOmapValsCR::request_complete() +{ + int r = cn->completion()->get_return_value(); + + set_status() << "request complete; ret=" << r; + + return r; +} + RGWRadosRemoveOmapKeysCR::RGWRadosRemoveOmapKeysCR(rgw::sal::RGWRadosStore *_store, const rgw_raw_obj& _obj, const set& _keys) : RGWSimpleCoroutine(_store->ctx()), diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index e3a9e3c465a..23c75438d12 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -614,6 +614,31 @@ class RGWRadosGetOmapKeysCR : public RGWSimpleCoroutine { boost::intrusive_ptr cn; }; +class RGWRadosGetOmapValsCR : public RGWSimpleCoroutine { + public: + struct Result { + rgw_rados_ref ref; + std::map entries; + bool more = false; + }; + using ResultPtr = std::shared_ptr; + + RGWRadosGetOmapValsCR(rgw::sal::RGWRadosStore *_store, const rgw_raw_obj& _obj, + const string& _marker, int _max_entries, + ResultPtr result); + + int send_request() override; + int request_complete() override; + + private: + rgw::sal::RGWRadosStore *store; + rgw_raw_obj obj; + string marker; + int max_entries; + ResultPtr result; + boost::intrusive_ptr cn; +}; + class RGWRadosRemoveOmapKeysCR : public RGWSimpleCoroutine { rgw::sal::RGWRadosStore *store; -- 2.39.5