From: Pritha Srivastava Date: Mon, 18 Oct 2021 05:53:17 +0000 (+0530) Subject: rgw: role metadata handler invokes RGWRole interfaces. X-Git-Tag: v17.2.6~119^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a954e1f9ee9be1da2151a8d6b32145f3d146bf12;p=ceph.git rgw: role metadata handler invokes RGWRole interfaces. Removing references to RGW services and RGW Ctl. Signed-off-by: Pritha Srivastava (cherry picked from commit 04913ebd8eb09ae2c69d278ec7ad012ea1d3e158) --- diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 87d455e703ca..bee4cd0c9a42 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -39,8 +39,6 @@ set(librgw_common_srcs 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 diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index bc6c34e68bff..83d5b67a0cdf 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1382,7 +1382,7 @@ int RGWRados::init_svc(bool raw, const DoutPrefixProvider *dpp) int RGWRados::init_ctl(const DoutPrefixProvider *dpp) { - return ctl.init(&svc, dpp); + return ctl.init(&svc, store, dpp); } /** diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index 76907103fd5d..420021eb5b8a 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -22,6 +22,8 @@ #include "services/svc_zone.h" #include "services/svc_sys_obj.h" #include "services/svc_role.h" +#include "services/svc_meta_be_sobj.h" +#include "services/svc_meta.h" #define dout_subsys ceph_subsys_rgw @@ -34,86 +36,6 @@ const string RGWRole::role_oid_prefix = "roles."; const string RGWRole::role_path_oid_prefix = "role_paths."; const string RGWRole::role_arn_prefix = "arn:aws:iam::"; -int RGWRole::store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) -{ - RGWObjVersionTracker objv_tracker; - return role_ctl->store_info(*this, - y, - dpp, - RGWRoleCtl::PutParams(). - set_exclusive(exclusive). - set_objv_tracker(&objv_tracker)); -} - -// Creation time -auto generate_ctime() { - real_clock::time_point t = real_clock::now(); - - struct timeval tv; - real_clock::to_timeval(t, tv); - - char buf[30]; - struct tm result; - gmtime_r(&tv.tv_sec, &result); - strftime(buf,30,"%Y-%m-%dT%H:%M:%S", &result); - sprintf(buf + strlen(buf),".%dZ",(int)tv.tv_usec/1000); - string ct; - ct.assign(buf, strlen(buf)); - return ct; -} - - -int RGWRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) -{ - if (!validate_input(dpp)) { - ldpp_dout(dpp, 0) << "ERROR: invalid input " << dendl; - return -EINVAL; - } - - uuid_d new_role_id; - new_role_id.generate_random(); - - id = new_role_id.to_string(); - arn = role_arn_prefix + tenant + ":role" + path + name; - creation_date = generate_ctime(); - - - RGWObjVersionTracker objv_tracker; - return role_ctl->create(*this, y, dpp, - RGWRoleCtl::PutParams(). - set_exclusive(exclusive). - set_objv_tracker(&objv_tracker)); -} - -int RGWRole::delete_obj(const DoutPrefixProvider *dpp, optional_yield y) -{ - - int ret = read_name(dpp, y); - if (ret < 0) { - return ret; - } - - ret = read_info(dpp, y); - if (ret < 0) { - return ret; - } - - if (! perm_policy_map.empty()) { - return -ERR_DELETE_CONFLICT; - } - - RGWObjVersionTracker ot; - ret = role_ctl->delete_role(*this, y, dpp, - RGWRoleCtl::RemoveParams(). - set_objv_tracker(&ot)); - if (ret < 0) { - ldpp_dout(dpp, 0) << "ERROR: deleting role: "<< id - << cpp_strerror(-ret) << dendl; - } - - return ret; -} - int RGWRole::get(const DoutPrefixProvider *dpp, optional_yield y) { int ret = read_name(dpp, y); @@ -225,54 +147,6 @@ void RGWRole::decode_json(JSONObj *obj) JSONDecoder::decode_json("AssumeRolePolicyDocument", trust_policy, obj); } -int RGWRole::read_id(const DoutPrefixProvider *dpp, const std::string& role_name, const std::string& tenant, std::string& role_id, optional_yield y) -{ - int ret; - RGWObjVersionTracker ot; - std::tie(ret, role_id) = role_ctl->read_name(role_name, tenant, y, dpp, - RGWRoleCtl::GetParams(). - set_objv_tracker(&ot)); - if (ret < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed reading role id with params" - << role_name << ", " << tenant << ":" - << cpp_strerror(ret) << dendl; - } - - return ret; -} - -int RGWRole::read_info(const DoutPrefixProvider *dpp, optional_yield y) -{ - - RGWObjVersionTracker ot; - auto ret = role_ctl->read_info(id, y, dpp, this, - RGWRoleCtl::GetParams(). - set_objv_tracker(&ot)); - if (ret < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed reading role info from pool: " - ": " << id << ": " << cpp_strerror(-ret) << dendl; - return ret; - } - - return 0; -} - -int RGWRole::read_name(const DoutPrefixProvider *dpp, optional_yield y) -{ - RGWObjVersionTracker ot; - auto [ret, _id] = role_ctl->read_name(name, tenant, y, dpp, - RGWRoleCtl::GetParams(). - set_objv_tracker(&ot)); - if (ret < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed reading role name from pool: " - << name << ": " << cpp_strerror(-ret) << dendl; - return ret; - } - - id = _id; - return 0; -} - bool RGWRole::validate_input(const DoutPrefixProvider* dpp) { if (name.length() > MAX_ROLE_NAME_LEN) { @@ -359,203 +233,89 @@ const string& RGWRole::get_path_oid_prefix() { return role_path_oid_prefix; } -} } // namespace rgw::sal -int RGWRoleCtl::create(rgw::sal::RGWRole& role, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->create(op->ctx(), - role, - params.objv_tracker, - params.mtime, - params.exclusive, - params.attrs, - y, - dpp); - }); -} +class RGWSI_Role_Module : public RGWSI_MBSObj_Handler_Module { + RGWRoleMetadataHandler::Svc& svc; + const std::string prefix; +public: + RGWSI_Role_Module(RGWRoleMetadataHandler::Svc& _svc): RGWSI_MBSObj_Handler_Module("roles"), + svc(_svc), + prefix(rgw::sal::RGWRole::get_info_oid_prefix()) {} -int RGWRoleCtl::store_info(const rgw::sal::RGWRole& role, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->store_info(op->ctx(), - role, - params.objv_tracker, - params.mtime, - params.exclusive, - params.attrs, - y, dpp); - }); -} + void get_pool_and_oid(const std::string& key, + rgw_pool *pool, + std::string *oid) override + { + if (pool) { + *pool = svc.zone->get_zone_params().roles_pool; + } -int RGWRoleCtl::store_name(const std::string& role_id, - const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->store_name(op->ctx(), - role_id, - name, - tenant, - params.objv_tracker, - params.mtime, - params.exclusive, - y, dpp); - }); -} + if (oid) { + *oid = key_to_oid(key); + } + } -int RGWRoleCtl::store_path(const std::string& role_id, - const std::string& path, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->store_path(op->ctx(), - role_id, - path, - tenant, - params.objv_tracker, - params.mtime, - params.exclusive, - y, dpp); - }); -} + bool is_valid_oid(const std::string& oid) override { + return boost::algorithm::starts_with(oid, prefix); + } -int -RGWRoleCtl::read_info(const std::string& role_id, - optional_yield y, - const DoutPrefixProvider *dpp, - rgw::sal::RGWRole* info, - const GetParams& params) -{ - int ret = be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->read_info(op->ctx(), - role_id, - info, - params.objv_tracker, - params.mtime, - params.attrs, - y, dpp); - }); - return ret; -} + std::string key_to_oid(const std::string& key) override { + return prefix + key; + } -std::pair -RGWRoleCtl::read_name(const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const GetParams& params) -{ - std::string role_id; - int ret = be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->read_name(op->ctx(), - name, - tenant, - role_id, - params.objv_tracker, - params.mtime, - y, dpp); - }); - return make_pair(ret, role_id); -} + // This is called after `is_valid_oid` and is assumed to be a valid oid + std::string oid_to_key(const std::string& oid) override { + return oid.substr(prefix.size()); + } -int RGWRoleCtl::delete_role(const rgw::sal::RGWRole& info, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->delete_role(op->ctx(), - info, - params.objv_tracker, - y, dpp); - }); - return 0; -} + const std::string& get_oid_prefix() { + return prefix; + } +}; -int RGWRoleCtl::delete_info(const std::string& role_id, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params) +RGWSI_MetaBackend_Handler* RGWRoleMetadataHandler::get_be_handler() { - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->delete_info(op->ctx(), - role_id, - params.objv_tracker, - y, dpp); - }); - return 0; + return be_handler; } -int RGWRoleCtl::delete_name(const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params) +void RGWRoleMetadataHandler::init(RGWSI_Zone *_zone_svc, + RGWSI_Meta *_meta_svc, + RGWSI_MetaBackend *_meta_be_svc, + RGWSI_SysObj *_sysobj_svc) { - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->delete_name(op->ctx(), - name, - tenant, - params.objv_tracker, - y, dpp); - }); + svc.zone = _zone_svc; + svc.meta = _meta_svc; + svc.meta_be = _meta_be_svc; + svc.sysobj = _sysobj_svc; } -int RGWRoleCtl::delete_path(const std::string& role_id, - const std::string& path, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params) +int RGWRoleMetadataHandler::do_start(optional_yield y, const DoutPrefixProvider *dpp) { - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->delete_path(op->ctx(), - role_id, - path, - tenant, - params.objv_tracker, - y, dpp); - }); -} -int RGWRoleCtl::list_roles_by_path_prefix(const std::string& path_prefix, - const std::string& tenant, - std::vector& roles, - optional_yield y, - const DoutPrefixProvider *dpp) -{ - return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.role->list_roles_by_path_prefix(op->ctx(), - path_prefix, - tenant, - roles, - y, - dpp); - }); + int r = svc.meta->create_be_handler(RGWSI_MetaBackend::Type::MDBE_SOBJ, + &be_handler); + if (r < 0) { + //ldout(ctx(), 0) << "ERROR: failed to create be_handler for Roles: r=" + // << r <(be_handler); + be_module.reset(module); + bh->set_module(module); + return 0; } -RGWRoleMetadataHandler::RGWRoleMetadataHandler(RGWSI_Role *role_svc) +RGWRoleMetadataHandler::RGWRoleMetadataHandler(CephContext *cct, Store* store) { - base_init(role_svc->ctx(), role_svc->get_be_handler()); - svc.role = role_svc; + base_init(cct, get_be_handler()); + store = store; } void RGWRoleCompleteInfo::dump(ceph::Formatter *f) const { - info.dump(f); + info->dump(f); if (has_attrs) { encode_json("attrs", attrs, f); } @@ -563,7 +323,7 @@ void RGWRoleCompleteInfo::dump(ceph::Formatter *f) const void RGWRoleCompleteInfo::decode_json(JSONObj *obj) { - decode_json_obj(info, obj); + decode_json_obj(*info, obj); has_attrs = JSONDecoder::decode_json("attrs", attrs, obj); } @@ -593,6 +353,7 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op, RGWObjVersionTracker objv_tracker; real_time mtime; +#if 0 int ret = svc.role->read_info(op->ctx(), entry, &rci.info, @@ -601,7 +362,9 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op, &rci.attrs, y, dpp); - +#endif + rci.info = store->get_role(entry).get(); + int ret = rci.info->read_info(dpp, y); if (ret < 0) { return ret; } @@ -619,14 +382,21 @@ int RGWRoleMetadataHandler::do_remove(RGWSI_MetaBackend_Handler::Op *op, optional_yield y, const DoutPrefixProvider *dpp) { - rgw::sal::RGWRole info; - real_time _mtime; +#if 0 int ret = svc.role->read_info(op->ctx(), entry, &info, &objv_tracker, &_mtime, nullptr, y, dpp); if (ret < 0) { return ret == -ENOENT ? 0 : ret; } return svc.role->delete_role(op->ctx(), info, &objv_tracker, y, dpp); +#endif + std::unique_ptr role = store->get_role(entry); + int ret = role->read_info(dpp, y); + if (ret < 0) { + return ret == -ENOENT? 0 : ret; + } + + return role->delete_obj(dpp, y); } class RGWMetadataHandlerPut_Role : public RGWMetadataHandlerPut_SObj @@ -651,8 +421,8 @@ public: auto& rci = mdo->get_rci(); auto mtime = mdo->get_mtime(); map *pattrs = rci.has_attrs ? &rci.attrs : nullptr; - - int ret = rhandler->svc.role->create(op->ctx(), +#if 0 + int ret = rhandler->role->create(op->ctx(), rci.info, &objv_tracker, mtime, @@ -662,6 +432,9 @@ public: dpp); return ret < 0 ? ret : STATUS_APPLIED; +#endif + int ret = rci.info->create(dpp, true, y); + return ret < 0 ? ret : STATUS_APPLIED; } }; @@ -677,3 +450,5 @@ int RGWRoleMetadataHandler::do_put(RGWSI_MetaBackend_Handler::Op *op, RGWMetadataHandlerPut_Role put_op(this, op , entry, obj, objv_tracker, y, type, from_remote_zone); return do_put_operate(&put_op, dpp); } + +} } // namespace rgw::sal diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index ffb48e2bf182..03a21eb6d3ef 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -15,7 +15,6 @@ class RGWCtl; class RGWRados; -class RGWRoleMetadataHandler; class RGWSI_Role; class RGWSI_MetaBackend_Handler; class RGWRoleCtl; @@ -48,12 +47,12 @@ protected: std::multimap tags; public: - virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y); - virtual int store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) { return 0; } - virtual int store_path(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) { return 0; } - virtual int read_id(const DoutPrefixProvider *dpp, const std::string& role_name, const std::string& tenant, std::string& role_id, optional_yield y); - virtual int read_name(const DoutPrefixProvider *dpp, optional_yield y); - virtual int read_info(const DoutPrefixProvider *dpp, optional_yield y); + virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 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; bool validate_input(const DoutPrefixProvider* dpp); void extract_name_tenant(const std::string& str); @@ -125,11 +124,12 @@ public: const uint64_t& get_max_session_duration() const { return max_session_duration; } void set_id(const std::string& id) { this->id = id; } + //TODO: Remove the following two void set_arn(const std::string& arn) { this->arn = arn; } void set_creation_date(const std::string& creation_date) { this->creation_date = creation_date; } - virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y); - virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y); + virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 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); int update(const DoutPrefixProvider *dpp, optional_yield y); @@ -149,10 +149,9 @@ public: static const std::string& get_path_oid_prefix(); }; WRITE_CLASS_ENCODER(RGWRole) -} } // namespace rgw::sal struct RGWRoleCompleteInfo { - rgw::sal::RGWRole info; + RGWRole* info; std::map attrs; bool has_attrs; @@ -176,17 +175,27 @@ public: return rci; } }; -//class RGWMetadataObject; class RGWRoleMetadataHandler: public RGWMetadataHandler_GenericMetaBE { - public: struct Svc { - RGWSI_Role *role{nullptr}; + RGWSI_Zone *zone{nullptr}; + RGWSI_Meta *meta{nullptr}; + RGWSI_MetaBackend *meta_be{nullptr}; + RGWSI_SysObj *sysobj{nullptr}; } svc; - RGWRoleMetadataHandler(RGWSI_Role *role_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); std::string get_type() final { return "roles"; } @@ -214,158 +223,12 @@ public: const DoutPrefixProvider *dpp, RGWMDLogSyncType type, bool from_remote_zone) override; -}; - -/// Defines control classes that call the low level service layer that handles -/// storage, svc classes implement the low level object operations. Ctl classes -/// can span over multiple service classes, for eg. User Ctl classes need to -/// update the user indices when buckets are added/removed RoleCtl classes may -/// need to update the RGW Account class that a role has been added deleted -/// under an account. -class RGWRoleCtl { - struct Svc { - RGWSI_Role *role {nullptr}; - } svc; - RGWRoleMetadataHandler *rmhandler; - RGWSI_MetaBackend_Handler *be_handler{nullptr}; -public: - RGWRoleCtl(RGWSI_Role *_role_svc, - RGWRoleMetadataHandler *_rmhandler) { - svc.role = _role_svc; - rmhandler = _rmhandler; - be_handler = _rmhandler->get_be_handler(); - } - - struct PutParams { - ceph::real_time mtime; - bool exclusive {false}; - RGWObjVersionTracker *objv_tracker {nullptr}; - std::map *attrs {nullptr}; - - PutParams() {} - - PutParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { - objv_tracker = _objv_tracker; - return *this; - } - - PutParams& set_mtime(const ceph::real_time& _mtime) { - mtime = _mtime; - return *this; - } - - PutParams& set_exclusive(bool _exclusive) { - exclusive = _exclusive; - return *this; - } - PutParams& set_attrs(std::map *_attrs) { - attrs = _attrs; - return *this; - } - }; - - struct GetParams { - ceph::real_time *mtime{nullptr}; - std::map *attrs{nullptr}; - RGWObjVersionTracker *objv_tracker {nullptr}; - - GetParams() {} - - GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { - objv_tracker = _objv_tracker; - return *this; - } - - GetParams& set_mtime(ceph::real_time *_mtime) { - mtime = _mtime; - return *this; - } - - GetParams& set_attrs(std::map *_attrs) { - attrs = _attrs; - return *this; - } - }; - - struct RemoveParams { - RGWObjVersionTracker *objv_tracker{nullptr}; - - RemoveParams() {} - - RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { - objv_tracker = _objv_tracker; - return *this; - } - }; - - - int create(rgw::sal::RGWRole& role, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params = {}); - - int store_info(const rgw::sal::RGWRole& role, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params = {}); - - // The methods for store name & store path are currently unused and only - // useful for a potential rename name/path functionality in the future as - // create role would automatically create these for most uses - int store_name(const std::string& role_id, - const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params = {}); - - int store_path(const std::string& role_id, - const std::string& path, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const PutParams& params = {}); - - int read_info(const std::string& role_id, - optional_yield y, - const DoutPrefixProvider *dpp, - rgw::sal::RGWRole* role, - const GetParams& params = {}); - - std::pair read_name(const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const GetParams& params = {}); - - int delete_role(const rgw::sal::RGWRole& role, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params = {}); - - int delete_info(const std::string& role_id, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params = {}); - - int delete_name(const std::string& name, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params = {}); - - int delete_path(const std::string& role_id, - const std::string& path, - const std::string& tenant, - optional_yield y, - const DoutPrefixProvider *dpp, - const RemoveParams& params = {}); - - int list_roles_by_path_prefix(const std::string& path_prefix, - const std::string& tenant, - std::vector& roles, - optional_yield y, - const DoutPrefixProvider *dpp); +private: + RGWSI_MetaBackend_Handler *be_handler; + std::unique_ptr be_module; + std::unique_ptr store; }; +} } // namespace rgw::sal + #endif /* CEPH_RGW_ROLE_H */ diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 8c9f9ef031b7..7798b9dd7205 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -36,6 +36,8 @@ #include "rgw_service.h" #include "rgw_lc.h" #include "services/svc_sys_obj.h" +#include "services/svc_meta.h" +#include "services/svc_meta_be_sobj.h" #include "services/svc_zone.h" #include "services/svc_tier_rados.h" #include "services/svc_quota.h" @@ -3084,7 +3086,6 @@ int RadosRole::delete_obj(const DoutPrefixProvider *dpp, optional_yield y) return ret; } - } // namespace rgw::sal extern "C" { diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 4e4673c03280..b5e21b4f9259 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -809,6 +809,7 @@ public: std::string max_session_duration, std::multimap tags) : RGWRole(name, tenant, path, trust_policy, max_session_duration, tags), store(_store) {} RadosRole(RadosStore* _store, std::string id) : RGWRole(id), store(_store) {} + RadosRole(RadosStore* _store) : store(_store) {} ~RadosRole() = default; virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override; @@ -820,7 +821,6 @@ public: virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) override; virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) override; }; - -} } // namespace rgw::sal +}} // namespace rgw::sal WRITE_CLASS_ENCODER(rgw::sal::RadosOIDCProvider) diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 33cc903603ee..537334b4cad0 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -36,6 +36,7 @@ #include "rgw_otp.h" #include "rgw_user.h" #include "rgw_role.h" +#include "rgw_sal_rados.h" #define dout_subsys ceph_subsys_rgw @@ -76,7 +77,7 @@ int RGWServices_Def::init(CephContext *cct, sysobj = std::make_unique(cct); sysobj_core = std::make_unique(cct); user_rados = std::make_unique(cct); - role_rados = std::make_unique(cct); + //role_rados = std::make_unique(store); if (have_cache) { sysobj_cache = std::make_unique(dpp, cct); @@ -116,7 +117,7 @@ int RGWServices_Def::init(CephContext *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()); + //role_rados->init(zone.get(), meta.get(), meta_be_sobj.get(), sysobj.get()); can_shutdown = true; @@ -249,7 +250,7 @@ int RGWServices_Def::init(CephContext *cct, return r; } - r = role_rados->start(y, dpp); + //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; @@ -323,7 +324,7 @@ int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_ cache = _svc.sysobj_cache.get(); core = _svc.sysobj_core.get(); user = _svc.user_rados.get(); - role = _svc.role_rados.get(); + //role = _svc.role_rados.get(); return 0; } @@ -355,7 +356,7 @@ RGWCtlDef::_meta::_meta() {} RGWCtlDef::_meta::~_meta() {} -int RGWCtlDef::init(RGWServices& svc, const DoutPrefixProvider *dpp) +int RGWCtlDef::init(RGWServices& svc, rgw::sal::Store* store, const DoutPrefixProvider *dpp) { meta.mgr.reset(new RGWMetadataManager(svc.meta)); @@ -371,7 +372,7 @@ int RGWCtlDef::init(RGWServices& svc, const DoutPrefixProvider *dpp) } meta.otp.reset(RGWOTPMetaHandlerAllocator::alloc()); - meta.role = std::make_unique(svc.role); + meta.role = std::make_unique(svc.cct, store); user.reset(new RGWUserCtl(svc.zone, svc.user, (RGWUserMetadataHandler *)meta.user.get())); bucket.reset(new RGWBucketCtl(svc.zone, @@ -379,7 +380,7 @@ int RGWCtlDef::init(RGWServices& svc, const DoutPrefixProvider *dpp) svc.bucket_sync, svc.bi)); otp.reset(new RGWOTPCtl(svc.zone, svc.otp)); - role = std::make_unique(svc.role, static_cast(meta.role.get())); + //role = std::make_unique(svc.role, static_cast(meta.role.get())); RGWBucketMetadataHandlerBase *bucket_meta_handler = static_cast(meta.bucket.get()); RGWBucketInstanceMetadataHandlerBase *bi_meta_handler = static_cast(meta.bucket_instance.get()); @@ -402,12 +403,12 @@ int RGWCtlDef::init(RGWServices& svc, const DoutPrefixProvider *dpp) return 0; } -int RGWCtl::init(RGWServices *_svc, const DoutPrefixProvider *dpp) +int RGWCtl::init(RGWServices *_svc, rgw::sal::Store* store, const DoutPrefixProvider *dpp) { svc = _svc; cct = svc->cct; - int r = _ctl.init(*svc, dpp); + int r = _ctl.init(*svc, store, dpp); if (r < 0) { ldpp_dout(dpp, 0) << "ERROR: failed to start init ctls (" << cpp_strerror(-r) << dendl; return r; @@ -423,7 +424,7 @@ int RGWCtl::init(RGWServices *_svc, const DoutPrefixProvider *dpp) user = _ctl.user.get(); bucket = _ctl.bucket.get(); otp = _ctl.otp.get(); - role = _ctl.role.get(); + //role = _ctl.role.get(); r = meta.user->attach(meta.mgr); if (r < 0) { diff --git a/src/rgw/rgw_service.h b/src/rgw/rgw_service.h index 064f541ea536..e70db0d0e6be 100644 --- a/src/rgw/rgw_service.h +++ b/src/rgw/rgw_service.h @@ -12,6 +12,7 @@ #include "common/async/yield_context.h" #include "rgw/rgw_common.h" +//#include "rgw/rgw_sal_rados.h" struct RGWServices_Def; @@ -65,8 +66,8 @@ class RGWSI_MetaBackend_OTP; class RGWSI_Notify; class RGWSI_OTP; class RGWSI_RADOS; -class RGWSI_Role; -class RGWSI_Role_RADOS; +//class RGWSI_Role; +//class RGWSI_Role_RADOS; class RGWSI_Zone; class RGWSI_ZoneUtils; class RGWSI_Quota; @@ -77,6 +78,7 @@ class RGWSI_SysObj_Cache; class RGWSI_User; class RGWSI_User_RADOS; class RGWDataChangesLog; +class RGWRole; struct RGWServices_Def { @@ -106,7 +108,7 @@ struct RGWServices_Def std::unique_ptr sysobj_cache; std::unique_ptr user_rados; std::unique_ptr datalog_rados; - std::unique_ptr role_rados; + //std::unique_ptr role_rados; RGWServices_Def(); ~RGWServices_Def(); @@ -149,7 +151,7 @@ struct RGWServices RGWSI_SysObj_Cache *cache{nullptr}; RGWSI_SysObj_Core *core{nullptr}; RGWSI_User *user{nullptr}; - RGWSI_Role *role{nullptr}; + RGWRole *role{nullptr}; int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp); @@ -170,7 +172,7 @@ class RGWMetadataHandler; class RGWUserCtl; class RGWBucketCtl; class RGWOTPCtl; -class RGWRoleCtl; +//class RGWRoleCtl; struct RGWCtlDef { struct _meta { @@ -188,12 +190,12 @@ struct RGWCtlDef { std::unique_ptr user; std::unique_ptr bucket; std::unique_ptr otp; - std::unique_ptr role; + //std::unique_ptr role; RGWCtlDef(); ~RGWCtlDef(); - int init(RGWServices& svc, const DoutPrefixProvider *dpp); + int init(RGWServices& svc, rgw::sal::Store* store, const DoutPrefixProvider *dpp); }; struct RGWCtl { @@ -215,9 +217,9 @@ struct RGWCtl { RGWUserCtl *user{nullptr}; RGWBucketCtl *bucket{nullptr}; RGWOTPCtl *otp{nullptr}; - RGWRoleCtl *role{nullptr}; + //RGWRoleCtl *role{nullptr}; - int init(RGWServices *_svc, const DoutPrefixProvider *dpp); + int init(RGWServices *_svc, rgw::sal::Store* store, const DoutPrefixProvider *dpp); }; #endif