From: Pritha Srivastava Date: Wed, 27 Oct 2021 05:42:12 +0000 (+0530) Subject: rgw: code for handling mtime, object tracker and attrs X-Git-Tag: v17.2.6~119^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bab45d2f55b517957131937691db57b773f245d2;p=ceph.git rgw: code for handling mtime, object tracker and attrs needed for RGWRoleMetadataHandler. Signed-off-by: Pritha Srivastava (cherry picked from commit a1000262816e10fca38516028ba4e38099936adb) --- diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index dc5f8a2c0aeb..beefc2c60b50 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -370,9 +370,6 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op, const DoutPrefixProvider *dpp) { RGWRoleCompleteInfo rci; - RGWObjVersionTracker objv_tracker; - real_time mtime; - #if 0 int ret = svc.role->read_info(op->ctx(), entry, @@ -389,6 +386,9 @@ int RGWRoleMetadataHandler::do_get(RGWSI_MetaBackend_Handler::Op *op, return ret; } + RGWObjVersionTracker objv_tracker = rci.info->get_objv_tracker(); + real_time mtime = rci.info->get_mtime(); + RGWRoleMetadataObject *rdo = new RGWRoleMetadataObject(rci, objv_tracker.read_version, mtime); *obj = rdo; @@ -440,7 +440,6 @@ public: int put_checked(const DoutPrefixProvider *dpp) override { auto& rci = mdo->get_rci(); auto mtime = mdo->get_mtime(); - map *pattrs = rci.has_attrs ? &rci.attrs : nullptr; #if 0 int ret = rhandler->role->create(op->ctx(), rci.info, @@ -453,6 +452,7 @@ public: return ret < 0 ? ret : STATUS_APPLIED; #endif + rci.info->set_mtime(mtime); int ret = rci.info->create(dpp, true, y); return ret < 0 ? ret : STATUS_APPLIED; } diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index 3f3ac266ec6a..c1204c363f84 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -45,6 +45,9 @@ protected: std::string tenant; uint64_t max_session_duration; std::multimap tags; + std::map attrs; + RGWObjVersionTracker objv_tracker; + real_time mtime; public: virtual int store_info(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0; @@ -75,6 +78,7 @@ public: } else { max_session_duration = std::stoull(max_session_duration_str); } + mtime = real_time(); } RGWRole(std::string id) : id(std::move(id)) {} @@ -122,11 +126,14 @@ public: const std::string& get_create_date() const { return creation_date; } const std::string& get_assume_role_policy() const { return trust_policy;} const uint64_t& get_max_session_duration() const { return max_session_duration; } + const RGWObjVersionTracker& get_objv_tracker() const { return objv_tracker; } + const real_time& get_mtime() const { return mtime; } 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; } + void set_mtime(const real_time& mtime) { this->mtime = mtime; } virtual int create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) = 0; virtual int delete_obj(const DoutPrefixProvider *dpp, optional_yield y) = 0; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 7798b9dd7205..9134c97201a0 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -2832,12 +2832,14 @@ int RadosRole::store_info(const DoutPrefixProvider *dpp, bool exclusive, optiona if (!this->tags.empty()) { bufferlist bl_tags; encode(this->tags, bl_tags); - map attrs; attrs.emplace("tagging", bl_tags); - return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, real_time(), y, &attrs); } - return rgw_put_system_obj(dpp, obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, exclusive, nullptr, real_time(), y); + 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); } int RadosRole::store_name(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) @@ -2921,8 +2923,7 @@ int RadosRole::read_info(const DoutPrefixProvider *dpp, optional_yield y) std::string oid = get_info_oid_prefix() + id; bufferlist bl; - map attrs; - int ret = rgw_get_system_obj(obj_ctx, store->get_zone()->get_params().roles_pool, oid, bl, nullptr, nullptr, null_yield, dpp, &attrs, nullptr, boost::none, true); + 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;