From: Abhishek Lekshmanan Date: Mon, 2 Nov 2020 13:46:00 +0000 (+0100) Subject: svc: role: use the stat system obj call for checking presence X-Git-Tag: v17.2.6~119^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7fdda5ce2312d249b18b5caa3f170245ef96e24c;p=ceph.git svc: role: use the stat system obj call for checking presence Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 4aa53fffcf33e3b021ca5d2f456652c69b2d5e90) --- diff --git a/src/rgw/services/svc_role_rados.cc b/src/rgw/services/svc_role_rados.cc index 1dc0195b74fe..b38a3e28d78e 100644 --- a/src/rgw/services/svc_role_rados.cc +++ b/src/rgw/services/svc_role_rados.cc @@ -84,6 +84,7 @@ int RGWSI_Role_RADOS::do_start(optional_yield y, const DoutPrefixProvider *dpp) class PutRole { RGWSI_Role_RADOS* svc_role; + RGWSI_Role_RADOS::Svc *svc; RGWSI_MetaBackend::Context *ctx; rgw::sal::RGWRole& info; RGWObjVersionTracker *objv_tracker; @@ -94,7 +95,8 @@ class PutRole const DoutPrefixProvider *dpp; public: - PutRole(RGWSI_Role_RADOS* _svc, + PutRole(RGWSI_Role_RADOS* _svc_role, + RGWSI_Role_RADOS::Svc *_svc, RGWSI_MetaBackend::Context *_ctx, rgw::sal::RGWRole& _info, RGWObjVersionTracker *_ot, @@ -103,21 +105,19 @@ public: std::map *_pattrs, optional_yield _y, const DoutPrefixProvider *dpp) : - svc_role(_svc), ctx(_ctx), info(_info), objv_tracker(_ot), + svc_role(_svc_role), ctx(_ctx), info(_info), objv_tracker(_ot), mtime(_mtime), exclusive(_exclusive), pattrs(_pattrs), y(_y), dpp(dpp) {} int prepare() { if (exclusive) { - // TODO replace this with a stat call instead we don't really need to read - // the values here - real_time _mtime; - std::string name = info.get_name(); - std::string tenant = info.get_tenant(); - std::string id = info.get_id(); - - int ret = svc_role->read_name(ctx, name, tenant, id, - objv_tracker, &_mtime, y, dpp); + RGWSI_MetaBackend_SObj::Context_SObj *sys_ctx = static_cast(ctx); + auto& obj_ctx = *sys_ctx->obj_ctx; + + int ret = rgw_stat_system_obj(dpp, obj_ctx, + svc->zone->get_zone_params().roles_pool, + svc_role->get_role_name_meta_key(info.get_name(), info.get_tenant()), + nullptr, nullptr, y); if (ret == 0) { ldout(svc_role->ctx(), 0) << "ERROR: name " << info.get_name() << " already in use for role id " @@ -168,7 +168,7 @@ int RGWSI_Role_RADOS::create(RGWSI_MetaBackend::Context *ctx, optional_yield y, const DoutPrefixProvider *dpp) { - PutRole Op(this, ctx, info, objv_tracker, mtime, exclusive, pattrs, y, dpp); + PutRole Op(this, &svc, ctx, info, objv_tracker, mtime, exclusive, pattrs, y, dpp); int r = Op.prepare(); if (r < 0) {