]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: code for handling mtime, object tracker and attrs
authorPritha Srivastava <prsrivas@redhat.com>
Wed, 27 Oct 2021 05:42:12 +0000 (11:12 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 6 Sep 2022 06:09:51 +0000 (11:39 +0530)
needed for RGWRoleMetadataHandler.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
(cherry picked from commit a1000262816e10fca38516028ba4e38099936adb)

src/rgw/rgw_role.cc
src/rgw/rgw_role.h
src/rgw/rgw_sal_rados.cc

index dc5f8a2c0aebeaaf5c128a45f20ab6045e3df095..beefc2c60b509eb8f8ea1c34ea2f4a4c494ccfc1 100644 (file)
@@ -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<std::string, bufferlist> *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;
   }
index 3f3ac266ec6ad914c6c819411630bdbebb0d3b36..c1204c363f8427d8bfee55d3d63959b0841826fe 100644 (file)
@@ -45,6 +45,9 @@ protected:
   std::string tenant;
   uint64_t max_session_duration;
   std::multimap<std::string,std::string> tags;
+  std::map<std::string, bufferlist> 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;
index 7798b9dd720582ccf540a3e0e1c28c1105348f70..9134c97201a035b5d48d613d842972438b6a51c0 100644 (file)
@@ -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<string, bufferlist> 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<string, bufferlist> 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;