]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: PubObj uses RGWObjTags by value
authorCasey Bodley <cbodley@redhat.com>
Fri, 28 Jun 2024 17:02:12 +0000 (13:02 -0400)
committerAlex Wojno <awojno@bloomberg.net>
Fri, 28 Jun 2024 17:03:32 +0000 (13:03 -0400)
stop wrapping RGWObjTags in a unique_ptr, and just use empty() or count() to determine whether any tags are present

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc

index c0821e78c5baa76080b8259167385585a8cda1f5..d2b8b1fdf8ad98793f8b1f0c5039cc5675c78ed4 100644 (file)
@@ -3947,11 +3947,8 @@ int RGWPutObj::verify_permission(optional_yield y)
 
   rgw_add_to_iam_environment(s->env, "s3:x-amz-acl", s->canned_acl);
 
-  if (obj_tags != nullptr && obj_tags->count() > 0){
-    auto tags = obj_tags->get_tags();
-    for (const auto& kv: tags){
-      rgw_add_to_iam_environment(s->env, "s3:RequestObjectTag/"+kv.first, kv.second);
-    }
+  for (const auto& kv: obj_tags.get_tags()) {
+    rgw_add_to_iam_environment(s->env, "s3:RequestObjectTag/"+kv.first, kv.second);
   }
 
   // add server-side encryption headers
@@ -4211,7 +4208,7 @@ void RGWPutObj::execute(optional_yield y)
                       s->object.get(), s->src_object.get(), s,
                       rgw::notify::ObjectCreatedPut, y);
   if(!multipart) {
-    op_ret = res->publish_reserve(this, obj_tags.get());
+    op_ret = res->publish_reserve(this, &obj_tags);
     if (op_ret < 0) {
       return;
     }
@@ -4509,7 +4506,7 @@ void RGWPutObj::execute(optional_yield y)
     return;
   }
   encode_delete_at_attr(delete_at, attrs);
-  encode_obj_tags_attr(obj_tags.get(), attrs);
+  encode_obj_tags_attr(obj_tags, attrs);
   rgw_cond_decode_objtags(s, attrs);
 
   /* Add a custom metadata to expose the information whether an object
index 5818c93f4d322587563422c8a9e0aa7c3bfe379a..afd5f8a685b715cc6edaf5eb497f2c3e06681c61 100644 (file)
@@ -1227,7 +1227,7 @@ protected:
   std::string etag;
   bool chunked_upload;
   RGWAccessControlPolicy policy;
-  std::unique_ptr <RGWObjTags> obj_tags;
+  RGWObjTags obj_tags;
   const char *dlo_manifest;
   RGWSLOInfo *slo_info;
   rgw::sal::Attrs attrs;
@@ -2218,18 +2218,14 @@ inline void encode_delete_at_attr(boost::optional<ceph::real_time> delete_at,
   attrs[RGW_ATTR_DELETE_AT] = delatbl;
 } /* encode_delete_at_attr */
 
-inline void encode_obj_tags_attr(RGWObjTags* obj_tags, std::map<std::string, bufferlist>& attrs)
+inline void encode_obj_tags_attr(const RGWObjTags& obj_tags, std::map<std::string, bufferlist>& attrs)
 {
-  if (obj_tags == nullptr){
-    // we assume the user submitted a tag format which we couldn't parse since
-    // this wouldn't be parsed later by get/put obj tags, lets delete if the
-    // attr was populated
+  if (obj_tags.empty()) {
     return;
   }
-
   bufferlist tagsbl;
-  obj_tags->encode(tagsbl);
-  attrs[RGW_ATTR_TAGS] = tagsbl;
+  obj_tags.encode(tagsbl);
+  attrs[RGW_ATTR_TAGS] = std::move(tagsbl);
 }
 
 inline int encode_dlo_manifest_attr(const char * const dlo_manifest,
index 40dee2e2398a6b74beab61494ab70fb94790d701..e7316485a972c9695a8b858674b8c97525a90bad 100644 (file)
@@ -2591,8 +2591,7 @@ int RGWPutObj_ObjStore_S3::get_params(optional_yield y)
   /* handle object tagging */
   auto tag_str = s->info.env->get("HTTP_X_AMZ_TAGGING");
   if (tag_str){
-    obj_tags = std::make_unique<RGWObjTags>();
-    ret = obj_tags->set_from_string(tag_str);
+    ret = obj_tags.set_from_string(tag_str);
     if (ret < 0){
       ldpp_dout(this,0) << "setting obj tags failed with " << ret << dendl;
       if (ret == -ERR_INVALID_TAG){