From f94164e427f0a64d7c2ada0acbe6002ceedfdd80 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 18 Aug 2015 13:43:39 -0700 Subject: [PATCH] rgw: coroutie for omap_get_vals() Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index bc7a39b6c7900..c1c86680f5989 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -593,6 +593,57 @@ public: } }; +class RGWRadosGetOmapKeysCR : public RGWSimpleCoroutine { + RGWAsyncRadosProcessor *async_rados; + RGWRados *store; + + string marker; + map *entries; + int max_entries; + + int rval; + + rgw_bucket pool; + string oid; + + RGWAioCompletionNotifier *cn; + +public: + RGWRadosGetOmapKeysCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, + rgw_bucket& _pool, const string& _oid, + const string& _marker, + map *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()), + async_rados(_async_rados), + store(_store), + marker(_marker), + entries(_entries), max_entries(_max_entries), rval(0), + pool(_pool), oid(_oid), cn(NULL) { + } + + ~RGWRadosGetOmapKeysCR() { + } + + int send_request() { + librados::IoCtx ioctx; + librados::Rados *rados = store->get_rados_handle(); + int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */ + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl; + return r; + } + + librados::ObjectReadOperation op; + op.omap_get_vals(marker, max_entries, entries, &rval); + + cn = stack->create_completion_notifier(); + return ioctx.aio_operate(oid, cn->completion(), &op, NULL); + } + + int request_complete() { + return rval; + } +}; + class RGWSimpleRadosLockCR : public RGWSimpleCoroutine { RGWAsyncRadosProcessor *async_rados; RGWRados *store; -- 2.39.5