rados.
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
services/svc_quota.cc
services/svc_sync_modules.cc
services/svc_rados.cc
+ services/svc_role.cc
+ services/svc_role_rados.cc
services/svc_sys_obj.cc
services/svc_sys_obj_cache.cc
services/svc_sys_obj_core.cc
{
return role_path_oid_prefix;
}
-
+#if 0
class RGWSI_Role_Module : public RGWSI_MBSObj_Handler_Module {
RGWRoleMetadataHandler::Svc& svc;
const std::string prefix;
base_init(cct, get_be_handler());
}
-#if 0
+
int RGWRoleMetadataHandler::do_start(optional_yield y, const DoutPrefixProvider *dpp)
{
#endif
RGWRoleMetadataHandler::RGWRoleMetadataHandler(CephContext *cct, Store* store,
- RGWSI_Zone *_zone_svc,
- RGWSI_Meta *_meta_svc,
- RGWSI_MetaBackend *_meta_be_svc,
- RGWSI_SysObj *_sysobj_svc)
+ RGWSI_Role *role_svc)
{
this->cct = cct;
this->store = store;
- init(_zone_svc, _meta_svc, _meta_be_svc, _sysobj_svc);
+ base_init(role_svc->ctx(), role_svc->get_be_handler());
}
void RGWRoleCompleteInfo::dump(ceph::Formatter *f) const
const DoutPrefixProvider *dpp)
{
RGWRoleCompleteInfo rci;
- rci.info = store->get_role(entry).get();
- int ret = rci.info->read_info(dpp, y);
+ std::unique_ptr<rgw::sal::RGWRole> role = store->get_role(entry);
+ rci.info = role.get();
+ int ret = rci.info->read_info(dpp, y, false);
if (ret < 0) {
return ret;
}
const DoutPrefixProvider *dpp)
{
std::unique_ptr<rgw::sal::RGWRole> role = store->get_role(entry);
- int ret = role->read_info(dpp, y);
+ int ret = role->read_info(dpp, y, false);
if (ret < 0) {
return ret == -ENOENT? 0 : ret;
}
auto& rci = mdo->get_rci();
auto mtime = mdo->get_mtime();
rci.info->set_mtime(mtime);
- int ret = rci.info->create(dpp, true, y);
+ int ret = rci.info->create(dpp, true, y, false);
return ret < 0 ? ret : STATUS_APPLIED;
}
};
real_time mtime;
public:
- virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
+ virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix=true) = 0;
virtual int store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
virtual int store_path(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
virtual int read_id(const DoutPrefixProvider *dpp, const std::string& role_name, const std::string& tenant, std::string& role_id, optional_yield y) = 0;
virtual int read_name(const DoutPrefixProvider *dpp, optional_yield y) = 0;
- virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+ virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y, bool addprefix=true) = 0;
bool validate_input(const DoutPrefixProvider* dpp);
void extract_name_tenant(const std::string& str);
void set_id(const std::string& id) { this->id = id; }
void set_mtime(const real_time& mtime) { this->mtime = mtime; }
- virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0;
+ virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix=true) = 0;
virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0;
int get(const DoutPrefixProvider *dpp, optional_yield y);
int get_by_id(const DoutPrefixProvider *dpp, optional_yield y);
class RGWRoleMetadataHandler: public RGWMetadataHandler_GenericMetaBE
{
public:
+ public:
struct Svc {
- RGWSI_Zone *zone{nullptr};
- RGWSI_Meta *meta{nullptr};
- RGWSI_MetaBackend *meta_be{nullptr};
- RGWSI_SysObj *sysobj{nullptr};
+ RGWSI_Role *role{nullptr};
} svc;
- void init(RGWSI_Zone *_zone_svc,
- RGWSI_Meta *_meta_svc,
- RGWSI_MetaBackend *_meta_be_svc,
- RGWSI_SysObj *_sysobj_svc);
-
- RGWSI_MetaBackend_Handler * get_be_handler();
-
- //int do_start(optional_yield y, const DoutPrefixProvider *dpp);
-
- RGWRoleMetadataHandler(CephContext *cct, Store* store,
- RGWSI_Zone *_zone_svc,
- RGWSI_Meta *_meta_svc,
- RGWSI_MetaBackend *_meta_be_svc,
- RGWSI_SysObj *_sysobj_svc);
+ RGWRoleMetadataHandler(CephContext *cct, Store* store, RGWSI_Role *role_svc);
std::string get_type() final { return "roles"; }
bool from_remote_zone) override;
private:
- RGWSI_MetaBackend_Handler *be_handler;
- std::unique_ptr<RGWSI_MetaBackend::Module> be_module;
Store* store;
CephContext *cct;
};
#include "services/svc_quota.h"
#include "services/svc_config_key.h"
#include "services/svc_zone_utils.h"
+#include "services/svc_role_rados.h"
#include "cls/rgw/cls_rgw_client.h"
#include "rgw_pubsub.h"
return ret;
}
-int RadosRole::store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y)
+int RadosRole::store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix)
{
using ceph::encode;
- //auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- std::string oid = get_info_oid_prefix() + id;
+ std::string oid;
+
+ if (addprefix) {
+ oid = get_info_oid_prefix() + id;
+ } else {
+ oid = id;
+ }
bufferlist bl;
encode(*this, bl);
}
RGWSI_MBSObj_PutParams params(bl, &attrs, mtime, exclusive);
- return store->svc()->meta_be_sobj->put(store->svc()->meta_be_sobj->alloc_ctx(), oid, params, &objv_tracker, y, dpp);
- #if 0
- if (!attrs.empty()) {
- return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, mtime, y, &attrs);
- }
-
- return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, mtime, y);
- #endif
+ std::unique_ptr<RGWSI_MetaBackend::Context> ctx(store->svc()->role->svc.meta_be->alloc_ctx());
+ ctx->init(store->svc()->role->get_be_handler());
+ return store->svc()->role->svc.meta_be->put(ctx.get(), oid, params, &objv_tracker, y, dpp);
}
int RadosRole::store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y)
return 0;
}
-int RadosRole::read_info(const DoutPrefixProvider *dpp, optional_yield y)
+int RadosRole::read_info(const DoutPrefixProvider *dpp, optional_yield y, bool addprefix)
{
- auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
- std::string oid = get_info_oid_prefix() + id;
+ //auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
+ std::string oid;
+ if (addprefix) {
+ oid = get_info_oid_prefix() + id;
+ } else {
+ oid = id;
+ }
bufferlist bl;
- int ret = rgw_get_system_obj(obj_ctx, store->svc()->zone->get_zone_params().roles_pool, oid, bl, &objv_tracker, &mtime, null_yield, dpp, &attrs, nullptr, boost::none, true);
+ RGWSI_MBSObj_GetParams params(&bl, &attrs, &mtime);
+ std::unique_ptr<RGWSI_MetaBackend::Context> ctx(store->svc()->role->svc.meta_be->alloc_ctx());
+ ctx->init(store->svc()->role->get_be_handler());
+ int ret = store->svc()->role->svc.meta_be->get_entry(ctx.get(), oid, params, &objv_tracker, y, dpp);
if (ret < 0) {
- ldpp_dout(dpp, 0) << "ERROR: failed reading role info from Role pool: " << id << ": " << cpp_strerror(-ret) << dendl;
return ret;
}
+#if 0
+ int ret = rgw_get_system_obj(obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, &objv_tracker, &mtime, null_yield, dpp, &attrs, nullptr, boost::none, true);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << "ERROR: failed reading role info from Role pool: " << id << ": " << cpp_strerror(-ret) << dendl;
+ return ret;
+ }
+#endif
try {
using ceph::decode;
auto iter = bl.cbegin();
return 0;
}
-int RadosRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y)
+int RadosRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix)
{
int ret;
creation_date.assign(buf, strlen(buf));
auto& pool = store->svc()->zone->get_zone_params().roles_pool;
- ret = store_info(dpp, exclusive, y);
+ ret = store_info(dpp, exclusive, y, addprefix);
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: storing role info in Role pool: "
<< id << ": " << cpp_strerror(-ret) << dendl;
RadosRole(RadosStore* _store) : store(_store) {}
~RadosRole() = default;
- virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override;
+ virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix=true) override;
virtual int store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override;
virtual int store_path(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override;
virtual int read_id(const DoutPrefixProvider *dpp, const std::string& role_name, const std::string& tenant, std::string& role_id, optional_yield y) override;
virtual int read_name(const DoutPrefixProvider *dpp, optional_yield y) override;
- virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y) override;
- virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override;
+ virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y, bool addprefix=true) override;
+ virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y, bool addprefix=true) override;
virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) override;
};
}} // namespace rgw::sal
sysobj = std::make_unique<RGWSI_SysObj>(cct);
sysobj_core = std::make_unique<RGWSI_SysObj_Core>(cct);
user_rados = std::make_unique<RGWSI_User_RADOS>(cct);
+ role_rados = std::make_unique<RGWSI_Role_RADOS>(cct);
if (have_cache) {
sysobj_cache = std::make_unique<RGWSI_SysObj_Cache>(dpp, cct);
}
user_rados->init(rados.get(), zone.get(), sysobj.get(), sysobj_cache.get(),
meta.get(), meta_be_sobj.get(), sync_modules.get());
+ role_rados->init(zone.get(), meta.get(), meta_be_sobj.get(), sysobj.get());
can_shutdown = true;
return r;
}
+ r = role_rados->start(y, dpp);
+ if (r < 0) {
+ ldout(cct, 0) << "ERROR: failed to start role_rados service (" << cpp_strerror(-r) << dendl;
+ return r;
+ }
+
}
/* cache or core services will be started by sysobj */
cache = _svc.sysobj_cache.get();
core = _svc.sysobj_core.get();
user = _svc.user_rados.get();
+ role = _svc.role_rados.get();
return 0;
}
}
meta.otp.reset(RGWOTPMetaHandlerAllocator::alloc());
- meta.role = std::make_unique<rgw::sal::RGWRoleMetadataHandler>(svc.cct, store, svc.zone, svc.meta, svc.meta_be_sobj, svc.sysobj);
+ meta.role = std::make_unique<rgw::sal::RGWRoleMetadataHandler>(svc.cct, store, svc.role);
user.reset(new RGWUserCtl(svc.zone, svc.user, (RGWUserMetadataHandler *)meta.user.get()));
bucket.reset(new RGWBucketCtl(svc.zone,
class RGWSI_User;
class RGWSI_User_RADOS;
class RGWDataChangesLog;
-class RGWRole;
+class RGWSI_Role;
+class RGWSI_Role_RADOS;
struct RGWServices_Def
{
std::unique_ptr<RGWSI_SysObj_Cache> sysobj_cache;
std::unique_ptr<RGWSI_User_RADOS> user_rados;
std::unique_ptr<RGWDataChangesLog> datalog_rados;
+ std::unique_ptr<RGWSI_Role_RADOS> role_rados;
RGWServices_Def();
~RGWServices_Def();
RGWSI_SysObj_Cache *cache{nullptr};
RGWSI_SysObj_Core *core{nullptr};
RGWSI_User *user{nullptr};
- RGWRole *role{nullptr};
+ RGWSI_Role_RADOS *role{nullptr};
int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp);
#include "svc_role.h"
-
-std::string RGWSI_Role::get_role_meta_key(const std::string& role_id)
-{
- return role_oid_prefix + role_id;
-}
-
-std::string RGWSI_Role::get_role_name_meta_key(const std::string& role_name, const std::string& tenant)
-{
- return tenant + role_name_oid_prefix + role_name;
-}
-
-std::string RGWSI_Role::get_role_path_meta_key(const std::string& path, const std::string& role_id, const std::string& tenant)
-{
- return tenant + role_path_oid_prefix + path + role_oid_prefix + role_id;
-}
virtual ~RGWSI_Role() {}
virtual RGWSI_MetaBackend_Handler* get_be_handler() = 0;
- static std::string get_role_meta_key(const std::string& role_id);
- static std::string get_role_name_meta_key(const std::string& role_name, const std::string& tenant);
- static std::string get_role_path_meta_key(const std::string& path, const std::string& role_id, const std::string& tenant);
-
- virtual int create(RGWSI_MetaBackend::Context *ctx,
- rgw::sal::RGWRole& role,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& pmtime,
- bool exclusive,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int store_info(RGWSI_MetaBackend::Context *ctx,
- const rgw::sal::RGWRole& role,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& mtime,
- bool exclusive,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int store_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& name,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& mtime,
- bool exclusive,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int store_path(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& path,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- const real_time &mtime,
- bool exclusive,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int read_info(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- rgw::sal::RGWRole *role, // out param
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int read_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& name,
- const std::string& tenant,
- std::string& role_id,
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int read_path(RGWSI_MetaBackend::Context *ctx,
- std::string& path,
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int delete_info(RGWSI_MetaBackend::Context *ctx,
- const std::string& id,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- // deletes a role from the system and the supporting objects
- virtual int delete_role(RGWSI_MetaBackend::Context *ctx,
- const rgw::sal::RGWRole& info,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int delete_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& name,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int delete_path(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& path,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
- virtual int list_roles_by_path_prefix(RGWSI_MetaBackend::Context *ctx,
- const std::string& path,
- const std::string& tenant,
- std::vector<rgw::sal::RGWRole>& roles, // out param
- optional_yield y,
- const DoutPrefixProvider *dpp) = 0;
-
};
static const std::string role_name_oid_prefix = "role_names.";
bh->set_module(module);
return 0;
}
-
+#if 0
class PutRole
{
RGWSI_Role_RADOS* svc_role;
});
return 0; // meta_be function calls have to return an int
}
+#endif
\ No newline at end of file
RGWSI_MetaBackend_Handler * get_be_handler() override;
int do_start(optional_yield y, const DoutPrefixProvider *dpp) override;
- int store_info(RGWSI_MetaBackend::Context *ctx,
- const rgw::sal::RGWRole& role,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& pmtime,
- bool exclusive,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int create(RGWSI_MetaBackend::Context *ctx,
- rgw::sal::RGWRole& role,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& pmtime,
- bool exclusive,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int store_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& name,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& mtime,
- bool exclusive,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int store_path(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& path,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- const real_time& mtime,
- bool exclusive,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int read_info(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- rgw::sal::RGWRole *role,
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- std::map<std::string, bufferlist> * pattrs,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int read_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& name,
- const std::string& tenant,
- std::string& role_id,
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int read_path(RGWSI_MetaBackend::Context *ctx,
- std::string& path,
- RGWObjVersionTracker * const objv_tracker,
- real_time * const pmtime,
- optional_yield y,
- const DoutPrefixProvider *dpp) override { return 0; } // TODO impl me
-
- int delete_role(RGWSI_MetaBackend::Context *ctx,
- const rgw::sal::RGWRole& info,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int delete_info(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int delete_name(RGWSI_MetaBackend::Context *ctx,
- const std::string& name,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int delete_path(RGWSI_MetaBackend::Context *ctx,
- const std::string& role_id,
- const std::string& path,
- const std::string& tenant,
- RGWObjVersionTracker * const objv_tracker,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
- int list_roles_by_path_prefix(RGWSI_MetaBackend::Context *ctx,
- const std::string& path,
- const std::string& tenant,
- std::vector<rgw::sal::RGWRole>& roles,
- optional_yield y,
- const DoutPrefixProvider *dpp) override;
-
private:
RGWSI_MetaBackend_Handler *be_handler;
std::unique_ptr<RGWSI_MetaBackend::Module> be_module;