summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@redhat.com>2019-06-06 23:31:19 +0200
committerCasey Bodley <cbodley@redhat.com>2019-07-29 21:20:48 +0200
commit6e9e302e0cfae874f5945e74361c786b978074f9 (patch)
tree88534be670215bfedbbbce3cff6784b3dc462436
parentrgw: RGWRados::lock_exclusive, ::unlock now being handled at svc.cls (diff)
downloadceph-6e9e302e0cfae874f5945e74361c786b978074f9.tar.xz
ceph-6e9e302e0cfae874f5945e74361c786b978074f9.zip
rgw: svc.be: don't alloc get params, use lambda
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
-rw-r--r--src/rgw/CMakeLists.txt1
-rw-r--r--src/rgw/services/svc_meta_be.cc5
-rw-r--r--src/rgw/services/svc_meta_be.h2
-rw-r--r--src/rgw/services/svc_meta_be_otp.cc27
-rw-r--r--src/rgw/services/svc_meta_be_otp.h7
-rw-r--r--src/rgw/services/svc_meta_be_sobj.cc12
-rw-r--r--src/rgw/services/svc_meta_be_sobj.h3
7 files changed, 27 insertions, 30 deletions
diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt
index b4a776b4afe..f1345c41fc9 100644
--- a/src/rgw/CMakeLists.txt
+++ b/src/rgw/CMakeLists.txt
@@ -27,6 +27,7 @@ set(librgw_common_srcs
services/svc_mdlog.cc
services/svc_meta.cc
services/svc_meta_be.cc
+ services/svc_meta_be_otp.cc
services/svc_meta_be_sobj.cc
services/svc_notify.cc
services/svc_quota.cc
diff --git a/src/rgw/services/svc_meta_be.cc b/src/rgw/services/svc_meta_be.cc
index dfb0b17984b..1fb1d1f04a1 100644
--- a/src/rgw/services/svc_meta_be.cc
+++ b/src/rgw/services/svc_meta_be.cc
@@ -48,9 +48,10 @@ int RGWSI_MetaBackend::prepare_mutate(RGWSI_MetaBackend::Context *ctx,
optional_yield y)
{
real_time orig_mtime;
- unique_ptr<GetParams> params(alloc_default_get_params(&orig_mtime));
- int ret = get_entry(ctx, key, *params, objv_tracker, y);
+ int ret = call_with_get_params(&orig_mtime, [&](GetParams& params) {
+ return get_entry(ctx, key, params, objv_tracker, y);
+ });
if (ret < 0 && ret != -ENOENT) {
return ret;
}
diff --git a/src/rgw/services/svc_meta_be.h b/src/rgw/services/svc_meta_be.h
index b20f8227e0b..f858c1e6ed4 100644
--- a/src/rgw/services/svc_meta_be.h
+++ b/src/rgw/services/svc_meta_be.h
@@ -121,7 +121,7 @@ public:
virtual Type get_type() = 0;
virtual RGWSI_MetaBackend_Handler *alloc_be_handler() = 0;
- virtual GetParams *alloc_default_get_params(ceph::real_time *pmtime) = 0;
+ virtual int call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)>) = 0;
/* these should be implemented by backends */
virtual int get_entry(RGWSI_MetaBackend::Context *ctx,
diff --git a/src/rgw/services/svc_meta_be_otp.cc b/src/rgw/services/svc_meta_be_otp.cc
index 9e565394b14..65674b69137 100644
--- a/src/rgw/services/svc_meta_be_otp.cc
+++ b/src/rgw/services/svc_meta_be_otp.cc
@@ -1,5 +1,5 @@
-#include "svc_meta_be_sobj.h"
+#include "svc_meta_be_otp.h"
#include "rgw/rgw_tools.h"
#include "rgw/rgw_metadata.h"
@@ -8,31 +8,24 @@
#define dout_subsys ceph_subsys_rgw
-RGWSI_MetaBackend_OTP::RGWSI_MetaBackend_OTP(CephContext *cct) : RGWSI_MetaBackend(cct) {
+RGWSI_MetaBackend_OTP::RGWSI_MetaBackend_OTP(CephContext *cct) : RGWSI_MetaBackend_SObj(cct) {
}
RGWSI_MetaBackend_OTP::~RGWSI_MetaBackend_OTP() {
}
-void RGWSI_MetaBackend_OTP::init_ctx(RGWSI_MetaBackend_Handle handle, RGWSI_MetaBackend::Context *_ctx)
+RGWSI_MetaBackend::Context *RGWSI_MetaBackend_SObj::alloc_ctx()
{
- RGWSI_MetaBackend_OTP::Context_OTP *ctx = static_cast<RGWSI_MetaBackend_OTP::Context_OTP *>(_ctx);
- rgwsi_meta_be_otp_handler_info *h = static_cast<rgwsi_meta_be_otp_handler_info *>(handle);
-
- ctx->handle = handle;
- ctx->module = h->module;
- ctx->section = h->section;
- ctx->obj_ctx.emplace(sysobj_svc->init_obj_ctx());
- static_cast<RGWSI_MBOTP_Handler_Module *>(ctx->module)->get_pool_and_oid(key, ctx->pool, ctx->oid);
+ return new Context_OTP(sysobj_svc);
}
-RGWSI_MetaBackend::GetParams *RGWSI_MetaBackend_OTP::alloc_default_get_params(ceph::real_time *pmtime)
+int RGWSI_MetaBackend_OTP::call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb)
{
- auto params = new RGWSI_MBOTP_GetParams;
- params->pmtime = pmtime;
- params->_devices = otp_devices_list_t();
- params->pdevices = &(*params->_devices);
- return params;
+ otp_device_list_t devices;
+ RGWSI_MBOTP_GetParams params;
+ params.pdevices = &devices;
+ params.pmtime = pmtime;
+ return cb(params);
}
int RGWSI_MetaBackend_SObj::get_entry(RGWSI_MetaBackend::Context *_ctx,
diff --git a/src/rgw/services/svc_meta_be_otp.h b/src/rgw/services/svc_meta_be_otp.h
index 137bf90f093..cc4b886d1cf 100644
--- a/src/rgw/services/svc_meta_be_otp.h
+++ b/src/rgw/services/svc_meta_be_otp.h
@@ -31,7 +31,6 @@ using RGWSI_MBOTP_Handler_Module = RGWSI_MBSObj_Handler_Module;
using otp_devices_list_t = list<rados::cls::otp::otp_info_t>;
struct RGWSI_MBOTP_GetParams : public RGWSI_MetaBackend::GetParams {
- std::optional<otp_devices_list_t> _devices;
otp_devices_list_t *pdevices{nullptr};
};
@@ -48,6 +47,10 @@ class RGWSI_MetaBackend_OTP : public RGWSI_MetaBackend_SObj
public:
struct Context_OTP : public RGWSI_MetaBackend_SObj::Context_SObj {
otp_devices_list_t devices;
+
+ void init(RGWSI_MetaBackend_Handler *h) override;
+
+ Context_SObj(RGWSI_SysObj*_sysobj_svc) : RGWSI_MetaBackend_SObj::Context_SObj(_sysobj_svc) {}
};
RGWSI_MetaBackend_OTP(CephContext *cct);
@@ -64,7 +67,7 @@ public:
cls_svc = _cls_svc;
}
- RGWSI_MetaBackend::GetParams *alloc_default_get_params(ceph::real_time *pmtime) override;
+ int call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb) override;
int get_entry(RGWSI_MetaBackend::Context *ctx,
const string& key,
diff --git a/src/rgw/services/svc_meta_be_sobj.cc b/src/rgw/services/svc_meta_be_sobj.cc
index 191564d8691..2638190e4a8 100644
--- a/src/rgw/services/svc_meta_be_sobj.cc
+++ b/src/rgw/services/svc_meta_be_sobj.cc
@@ -98,13 +98,13 @@ void RGWSI_MetaBackend_SObj::Context_SObj::init(RGWSI_MetaBackend_Handler *h)
obj_ctx.emplace(sysobj_svc->init_obj_ctx());
}
-RGWSI_MetaBackend::GetParams *RGWSI_MetaBackend_SObj::alloc_default_get_params(ceph::real_time *pmtime)
+int RGWSI_MetaBackend_SObj::call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb)
{
- auto params = new RGWSI_MBSObj_GetParams;
- params->pmtime = pmtime;
- params->_bl = bufferlist();
- params->pbl = &(*params->_bl);
- return params;
+ bufferlist bl;
+ RGWSI_MBSObj_GetParams params;
+ params.pmtime = pmtime;
+ params.pbl = &bl;
+ return cb(params);
}
int RGWSI_MetaBackend_SObj::get_entry(RGWSI_MetaBackend::Context *_ctx,
diff --git a/src/rgw/services/svc_meta_be_sobj.h b/src/rgw/services/svc_meta_be_sobj.h
index fda798aeedd..03e604f41a7 100644
--- a/src/rgw/services/svc_meta_be_sobj.h
+++ b/src/rgw/services/svc_meta_be_sobj.h
@@ -46,7 +46,6 @@ public:
};
struct RGWSI_MBSObj_GetParams : public RGWSI_MetaBackend::GetParams {
- std::optional<bufferlist> _bl;
bufferlist *pbl{nullptr};
map<string, bufferlist> *pattrs{nullptr};
rgw_cache_entry_info *cache_info{nullptr};
@@ -128,7 +127,7 @@ public:
RGWSI_MetaBackend::Context *alloc_ctx() override;
- RGWSI_MetaBackend::GetParams *alloc_default_get_params(ceph::real_time *pmtime) override;
+ int call_with_get_params(ceph::real_time *pmtime, std::function<int(RGWSI_MetaBackend::GetParams&)> cb) override;
int pre_modify(RGWSI_MetaBackend::Context *ctx,
const string& key,