]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Zipper - Replace RGWAttrs with a using
authorDaniel Gryniewicz <dang@redhat.com>
Tue, 18 Aug 2020 18:33:48 +0000 (14:33 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Tue, 8 Sep 2020 15:51:29 +0000 (11:51 -0400)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_file.h
src/rgw/rgw_op.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index 24e47b7d9bc8b401bc25ec19bb1fd48c19eac8e5..586fc8b56a1ea54a34b33d082cf94bab447331b3 100644 (file)
@@ -1353,7 +1353,7 @@ int check_min_obj_stripe_size(rgw::sal::RGWRadosStore *store, RGWBucketInfo& buc
 
   map<string, bufferlist>::iterator iter;
   iter = obj->get_attrs().find(RGW_ATTR_MANIFEST);
-  if (iter == obj->get_attrs().attrs.end()) {
+  if (iter == obj->get_attrs().end()) {
     *need_rewrite = (obj->get_obj_size() >= min_stripe_size);
     return 0;
   }
index 2984d5094f2a90be76e9ebeb68861f1b2098e7ac..d4a4d43be5a433527d36f80d4c387ba7674237da 100644 (file)
@@ -2130,7 +2130,7 @@ public:
   uint64_t get_size() { return _size; }
   real_time ctime() { return mod_time; } // XXX
   real_time mtime() { return mod_time; }
-  std::map<string, bufferlist>& get_attrs() { return attrs.attrs; }
+  std::map<string, bufferlist>& get_attrs() { return attrs; }
 
   buffer::list* get_attr(const std::string& k) {
     auto iter = attrs.find(k);
index 29a556853d9635bd128bde9a3171607f624e8d1c..6bebdb1df042de49ccbf2feec43e18370bfd8aa1 100644 (file)
@@ -573,9 +573,9 @@ int rgw_build_bucket_policies(rgw::sal::RGWRadosStore* store, struct req_state*
     }
 
     s->bucket_mtime = s->bucket->get_modification_time();
-    s->bucket_attrs = s->bucket->get_attrs().attrs;
+    s->bucket_attrs = s->bucket->get_attrs();
     ret = read_bucket_policy(store, s, s->bucket->get_info(),
-                            s->bucket->get_attrs().attrs,
+                            s->bucket->get_attrs(),
                             s->bucket_acl.get(), s->bucket->get_key());
     acct_acl_user = {
       s->bucket->get_info().owner,
@@ -629,7 +629,7 @@ int rgw_build_bucket_policies(rgw::sal::RGWRadosStore* store, struct req_state*
       return -EINVAL;
     }
 
-    s->bucket_access_conf = get_public_access_conf_from_attr(s->bucket->get_attrs().attrs);
+    s->bucket_access_conf = get_public_access_conf_from_attr(s->bucket->get_attrs());
   }
 
   /* handle user ACL only for those APIs which support it */
@@ -755,8 +755,8 @@ static int rgw_iam_add_existing_objtags(rgw::sal::RGWRadosStore* store, struct r
   if (op_ret < 0)
     return op_ret;
   rgw::sal::RGWAttrs attrs = s->object->get_attrs();
-  auto tags = attrs.attrs.find(RGW_ATTR_TAGS);
-  if (tags != attrs.attrs.end()){
+  auto tags = attrs.find(RGW_ATTR_TAGS);
+  if (tags != attrs.end()){
     return rgw_iam_add_tags_from_bl(s, tags->second);
   }
   return 0;
@@ -926,8 +926,8 @@ int RGWGetObj::verify_permission()
 // cache the objects tags into the requests
 // use inside try/catch as "decode()" may throw
 void populate_tags_in_request(req_state* s, const rgw::sal::RGWAttrs& attrs) {
-  const auto attr_iter = attrs.attrs.find(RGW_ATTR_TAGS);
-  if (attr_iter != attrs.attrs.end()) {
+  const auto attr_iter = attrs.find(RGW_ATTR_TAGS);
+  if (attr_iter != attrs.end()) {
     auto bliter = attr_iter->second.cbegin();
     decode(s->tagset, bliter);
   }
@@ -935,7 +935,7 @@ void populate_tags_in_request(req_state* s, const rgw::sal::RGWAttrs& attrs) {
 
 // cache the objects metadata into the request
 void populate_metadata_in_request(req_state* s, const rgw::sal::RGWAttrs& attrs) {
-  for (auto& attr : attrs.attrs) {
+  for (auto& attr : attrs) {
     if (boost::algorithm::starts_with(attr.first, RGW_ATTR_META_PREFIX)) {
       std::string_view key(attr.first);
       key.remove_prefix(sizeof(RGW_ATTR_PREFIX)-1);
@@ -1008,8 +1008,8 @@ void RGWGetObjTags::execute()
   }
 
   attrs = s->object->get_attrs();
-  auto tags = attrs.attrs.find(RGW_ATTR_TAGS);
-  if(tags != attrs.attrs.end()){
+  auto tags = attrs.find(RGW_ATTR_TAGS);
+  if(tags != attrs.end()){
     has_tags = true;
     tags_bl.append(tags->second);
   }
@@ -1531,7 +1531,7 @@ int RGWGetObj::read_user_manifest_part(rgw::sal::RGWBucket* bucket,
   if (op_ret < 0)
     return op_ret;
   bool need_decompress;
-  op_ret = rgw_compression_info_from_attrset(part->get_attrs().attrs, need_decompress, cs_info);
+  op_ret = rgw_compression_info_from_attrset(part->get_attrs(), need_decompress, cs_info);
   if (op_ret < 0) {
     ldpp_dout(this, 0) << "ERROR: failed to decode compression info" << dendl;
     return -EIO;
@@ -1558,7 +1558,7 @@ int RGWGetObj::read_user_manifest_part(rgw::sal::RGWBucket* bucket,
          }
   }
 
-  op_ret = rgw_policy_from_attrset(s->cct, part->get_attrs().attrs, &obj_policy);
+  op_ret = rgw_policy_from_attrset(s->cct, part->get_attrs(), &obj_policy);
   if (op_ret < 0)
     return op_ret;
 
@@ -1944,7 +1944,7 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl)
         }
         bucket = tmp_bucket.get();
         bucket_acl = &_bucket_acl;
-        r = read_bucket_policy(store, s, tmp_bucket->get_info(), tmp_bucket->get_attrs().attrs, bucket_acl,
+        r = read_bucket_policy(store, s, tmp_bucket->get_info(), tmp_bucket->get_attrs(), bucket_acl,
                                tmp_bucket->get_key());
         if (r < 0) {
           ldpp_dout(this, 0) << "failed to read bucket ACL for bucket "
@@ -1952,7 +1952,7 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl)
           return r;
        }
        auto _bucket_policy = get_iam_policy_from_attr(
-         s->cct, tmp_bucket->get_attrs().attrs, tmp_bucket->get_tenant());
+         s->cct, tmp_bucket->get_attrs(), tmp_bucket->get_tenant());
         bucket_policy = _bucket_policy.get_ptr();
        buckets[bucket_name].swap(tmp_bucket);
         policies[bucket_name] = make_pair(bucket_acl, _bucket_policy);
@@ -2142,7 +2142,7 @@ void RGWGetObj::execute()
   }
   /* end gettorrent */
 
-  op_ret = rgw_compression_info_from_attrset(attrs.attrs, need_decompress, cs_info);
+  op_ret = rgw_compression_info_from_attrset(attrs, need_decompress, cs_info);
   if (op_ret < 0) {
     ldpp_dout(s, 0) << "ERROR: failed to decode compression info, cannot decompress" << dendl;
     goto done_err;
@@ -2197,7 +2197,7 @@ void RGWGetObj::execute()
   }
 
   /* Decode S3 objtags, if any */
-  rgw_cond_decode_objtags(s, attrs.attrs);
+  rgw_cond_decode_objtags(s, attrs);
 
   start = ofs;
 
@@ -3218,7 +3218,7 @@ void RGWCreateBucket::execute()
         op_ret = -EEXIST;
         return;
       } else {
-        s->bucket_attrs = s->bucket->get_attrs().attrs;
+        s->bucket_attrs = s->bucket->get_attrs();
       }
 
       attrs.clear();
@@ -3632,7 +3632,7 @@ int RGWPutObj::get_data(const off_t fst, const off_t lst, bufferlist& bl)
   obj_size = obj->get_obj_size();
 
   bool need_decompress;
-  op_ret = rgw_compression_info_from_attrset(obj->get_attrs().attrs, need_decompress, cs_info);
+  op_ret = rgw_compression_info_from_attrset(obj->get_attrs(), need_decompress, cs_info);
   if (op_ret < 0) {
     ldpp_dout(s, 0) << "ERROR: failed to decode compression info" << dendl;
     return -EIO;
@@ -3649,7 +3649,7 @@ int RGWPutObj::get_data(const off_t fst, const off_t lst, bufferlist& bl)
   auto attr_iter = obj->get_attrs().find(RGW_ATTR_MANIFEST);
   op_ret = this->get_decrypt_filter(&decrypt,
                                     filter,
-                                    obj->get_attrs().attrs,
+                                    obj->get_attrs(),
                                     attr_iter != obj->get_attrs().end() ? &(attr_iter->second) : nullptr);
   if (decrypt != nullptr) {
     filter = decrypt.get();
@@ -4466,7 +4466,7 @@ void RGWPutMetadataBucket::execute()
     return;
   }
 
-  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs, false);
+  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs, false);
   if (op_ret < 0) {
     return;
   }
@@ -4503,15 +4503,15 @@ void RGWPutMetadataBucket::execute()
       /* It's supposed that following functions WILL NOT change any
        * special attributes (like RGW_ATTR_ACL) if they are already
        * present in attrs. */
-      prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs.attrs);
-      populate_with_generic_attrs(s, attrs.attrs);
+      prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
+      populate_with_generic_attrs(s, attrs);
 
       /* According to the Swift's behaviour and its container_quota
        * WSGI middleware implementation: anyone with write permissions
        * is able to set the bucket quota. This stays in contrast to
        * account quotas that can be set only by clients holding
        * reseller admin privileges. */
-      op_ret = filter_out_quota_info(attrs.attrs, rmattr_names, s->bucket->get_info().quota);
+      op_ret = filter_out_quota_info(attrs, rmattr_names, s->bucket->get_info().quota);
       if (op_ret < 0) {
        return op_ret;
       }
@@ -4522,7 +4522,7 @@ void RGWPutMetadataBucket::execute()
       }
 
       /* Web site of Swift API. */
-      filter_out_website(attrs.attrs, rmattr_names, s->bucket->get_info().website_conf);
+      filter_out_website(attrs, rmattr_names, s->bucket->get_info().website_conf);
       s->bucket->get_info().has_website = !s->bucket->get_info().website_conf.is_empty();
 
       /* Setting attributes also stores the provided bucket info. Due
@@ -4561,7 +4561,7 @@ void RGWPutMetadataObject::execute()
     return;
   }
 
-  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs);
+  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs);
   if (op_ret < 0) {
     return;
   }
@@ -4580,12 +4580,12 @@ void RGWPutMetadataObject::execute()
   }
 
   /* Filter currently existing attributes. */
-  prepare_add_del_attrs(s->object->get_attrs().attrs, attrs.attrs, rmattrs.attrs);
-  populate_with_generic_attrs(s, attrs.attrs);
-  encode_delete_at_attr(delete_at, attrs.attrs);
+  prepare_add_del_attrs(s->object->get_attrs(), attrs, rmattrs);
+  populate_with_generic_attrs(s, attrs);
+  encode_delete_at_attr(delete_at, attrs);
 
   if (dlo_manifest) {
-    op_ret = encode_dlo_manifest_attr(dlo_manifest, attrs.attrs);
+    op_ret = encode_dlo_manifest_attr(dlo_manifest, attrs);
     if (op_ret < 0) {
       ldpp_dout(this, 0) << "bad user manifest: " << dlo_manifest << dendl;
       return;
@@ -4745,8 +4745,8 @@ void RGWDeleteObj::execute()
     op_ret = 0;
 
     if (check_obj_lock) {
-      auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
-      if (aiter != attrs.attrs.end()) {
+      auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+      if (aiter != attrs.end()) {
         RGWObjectRetention obj_retention;
         try {
           decode(obj_retention, aiter->second);
@@ -4762,8 +4762,8 @@ void RGWDeleteObj::execute()
           }
         }
       }
-      aiter = attrs.attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
-      if (aiter != attrs.attrs.end()) {
+      aiter = attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
+      if (aiter != attrs.end()) {
         RGWObjectLegalHold obj_legal_hold;
         try {
           decode(obj_legal_hold, aiter->second);
@@ -4780,9 +4780,9 @@ void RGWDeleteObj::execute()
     }
 
     if (multipart_delete) {
-      const auto slo_attr = attrs.attrs.find(RGW_ATTR_SLO_MANIFEST);
+      const auto slo_attr = attrs.find(RGW_ATTR_SLO_MANIFEST);
 
-      if (slo_attr != attrs.attrs.end()) {
+      if (slo_attr != attrs.end()) {
         op_ret = handle_slo_manifest(slo_attr->second);
         if (op_ret < 0) {
           ldpp_dout(this, 0) << "ERROR: failed to handle slo manifest ret=" << op_ret << dendl;
@@ -4860,15 +4860,15 @@ void RGWDeleteObj::execute()
     // cache the objects tags and metadata into the requests
     // so it could be used in the notification mechanism
     try {
-      populate_tags_in_request(s, attrs.attrs);
+      populate_tags_in_request(s, attrs);
     } catch (buffer::error& err) {
       ldpp_dout(this, 5) << "WARNING: failed to populate delete request with object tags: " << err.what() << dendl;
     }
-    populate_metadata_in_request(s, attrs.attrs);
+    populate_metadata_in_request(s, attrs);
     const auto obj_state = obj_ctx->get_state(s->object->get_obj());
 
     // send request to notification manager
-    const auto ret = rgw::notify::publish_commit(s->object.get(), obj_state->size, obj_state->mtime, attrs.attrs[RGW_ATTR_ETAG].to_str(), event_type, res);
+    const auto ret = rgw::notify::publish_commit(s->object.get(), obj_state->size, obj_state->mtime, attrs[RGW_ATTR_ETAG].to_str(), event_type, res);
     if (ret < 0) {
       ldpp_dout(this, 1) << "ERROR: publishing notification failed, with error: " << ret << dendl;
       // too late to rollback operation, hence op_ret is not set here
@@ -4960,7 +4960,7 @@ int RGWCopyObj::verify_permission()
     rgw_placement_rule src_placement;
 
     /* check source object permissions */
-    op_ret = read_obj_policy(store, s, src_bucket->get_info(), src_bucket->get_attrs().attrs, &src_acl, &src_placement.storage_class,
+    op_ret = read_obj_policy(store, s, src_bucket->get_info(), src_bucket->get_attrs(), &src_acl, &src_placement.storage_class,
                             src_policy, src_bucket.get(), src_object.get());
     if (op_ret < 0) {
       return op_ret;
@@ -5028,12 +5028,12 @@ int RGWCopyObj::verify_permission()
 
   /* check dest bucket permissions */
   op_ret = read_bucket_policy(store, s, dest_bucket->get_info(),
-                             dest_bucket->get_attrs().attrs,
+                             dest_bucket->get_attrs(),
                               &dest_bucket_policy, dest_bucket->get_key());
   if (op_ret < 0) {
     return op_ret;
   }
-  auto dest_iam_policy = get_iam_policy_from_attr(s->cct, dest_bucket->get_attrs().attrs, dest_bucket->get_tenant());
+  auto dest_iam_policy = get_iam_policy_from_attr(s->cct, dest_bucket->get_attrs(), dest_bucket->get_tenant());
   /* admin request overrides permission checks */
   if (! s->auth.identity->is_admin_of(dest_policy.get_owner().get_id())){
     if (dest_iam_policy != boost::none) {
@@ -5092,11 +5092,11 @@ int RGWCopyObj::init_common()
   dest_policy.encode(aclbl);
   emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
 
-  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs);
+  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs);
   if (op_ret < 0) {
     return op_ret;
   }
-  populate_with_generic_attrs(s, attrs.attrs);
+  populate_with_generic_attrs(s, attrs);
 
   return 0;
 }
@@ -5148,7 +5148,7 @@ void RGWCopyObj::execute()
   src_object->set_atomic(&obj_ctx);
   dest_object->set_atomic(&obj_ctx);
 
-  encode_delete_at_attr(delete_at, attrs.attrs);
+  encode_delete_at_attr(delete_at, attrs);
 
   if (!s->system_request) { // no quota enforcement for system requests
     // get src object size (cached in obj_ctx from verify_permission())
@@ -6032,7 +6032,7 @@ void RGWCompleteMultipart::execute()
                     << " ret=" << op_ret << dendl;
     return;
   }
-  attrs = meta_obj->get_attrs().attrs;
+  attrs = meta_obj->get_attrs();
 
   do {
     op_ret = list_multipart_parts(store, s, upload_id, meta_oid, max_parts,
@@ -6617,7 +6617,7 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path)
     goto binfo_fail;
   }
 
-  if (!verify_permission(bucket->get_info(), bucket->get_attrs().attrs, bowner)) {
+  if (!verify_permission(bucket->get_info(), bucket->get_attrs(), bowner)) {
     ret = -EACCES;
     goto auth_fail;
   }
@@ -7008,7 +7008,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
 
   if (! handle_file_verify_permission(bucket->get_info(),
                                      obj->get_obj(),
-                                     bucket->get_attrs().attrs, bowner)) {
+                                     bucket->get_attrs(), bowner)) {
     ldpp_dout(this, 20) << "object creation unauthorized" << dendl;
     op_ret = -EACCES;
     return op_ret;
@@ -7750,8 +7750,8 @@ void RGWPutObjRetention::execute()
     return;
   }
   rgw::sal::RGWAttrs attrs = s->object->get_attrs();
-  auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
-  if (aiter != attrs.attrs.end()) {
+  auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+  if (aiter != attrs.end()) {
     RGWObjectRetention old_obj_retention;
     try {
       decode(old_obj_retention, aiter->second);
@@ -7800,8 +7800,8 @@ void RGWGetObjRetention::execute()
     return;
   }
   rgw::sal::RGWAttrs attrs = s->object->get_attrs();
-  auto aiter = attrs.attrs.find(RGW_ATTR_OBJECT_RETENTION);
-  if (aiter == attrs.attrs.end()) {
+  auto aiter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+  if (aiter == attrs.end()) {
     op_ret = -ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION;
     return;
   }
@@ -7894,8 +7894,8 @@ void RGWGetObjLegalHold::execute()
                        << " ret=" << op_ret << dendl;
     return;
   }
-  auto aiter = s->object->get_attrs().attrs.find(RGW_ATTR_OBJECT_LEGAL_HOLD);
-  if (aiter == s->object->get_attrs().attrs.end()) {
+  auto aiter = s->object->get_attrs().find(RGW_ATTR_OBJECT_LEGAL_HOLD);
+  if (aiter == s->object->get_attrs().end()) {
     op_ret = -ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION;
     return;
   }
index 281f259a69b867065d56e426e909305d0a822b20..add055ffa9ca0a041db0d77d8d761ce30bfa820e 100644 (file)
@@ -256,7 +256,7 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
     /* JSON encode object metadata */
     JSONFormatter jf;
     jf.open_object_section("obj_metadata");
-    encode_json("attrs", attrs.attrs, &jf);
+    encode_json("attrs", attrs, &jf);
     utime_t ut(lastmod);
     encode_json("mtime", ut, &jf);
     jf.close_section();
@@ -271,14 +271,14 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
     /* we end up dumping mtime in two different methods, a bit redundant */
     dump_epoch_header(s, "Rgwx-Mtime", lastmod);
     uint64_t pg_ver = 0;
-    int r = decode_attr_bl_single_value(attrs.attrs, RGW_ATTR_PG_VER, &pg_ver, (uint64_t)0);
+    int r = decode_attr_bl_single_value(attrs, RGW_ATTR_PG_VER, &pg_ver, (uint64_t)0);
     if (r < 0) {
       ldpp_dout(this, 0) << "ERROR: failed to decode pg ver attr, ignoring" << dendl;
     }
     dump_header(s, "Rgwx-Obj-PG-Ver", pg_ver);
 
     uint32_t source_zone_short_id = 0;
-    r = decode_attr_bl_single_value(attrs.attrs, RGW_ATTR_SOURCE_ZONE, &source_zone_short_id, (uint32_t)0);
+    r = decode_attr_bl_single_value(attrs, RGW_ATTR_SOURCE_ZONE, &source_zone_short_id, (uint32_t)0);
     if (r < 0) {
       ldpp_dout(this, 0) << "ERROR: failed to decode pg ver attr, ignoring" << dendl;
     }
@@ -444,7 +444,7 @@ int RGWGetObj_ObjStore_S3::get_decrypt_filter(std::unique_ptr<RGWGetObj_Filter>
 
   int res = 0;
   std::unique_ptr<BlockCrypt> block_crypt;
-  res = rgw_s3_prepare_decrypt(s, attrs.attrs, &block_crypt, crypt_http_responses);
+  res = rgw_s3_prepare_decrypt(s, attrs, &block_crypt, crypt_http_responses);
   if (res == 0) {
     if (block_crypt != nullptr) {
       auto f = std::make_unique<RGWGetObj_BlockDecrypt>(s->cct, cb, std::move(block_crypt));
@@ -4905,7 +4905,7 @@ int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {
       return -ERR_NO_SUCH_BUCKET;
   }
 
-  s->bucket_attrs = s->bucket->get_attrs().attrs;
+  s->bucket_attrs = s->bucket->get_attrs();
 
   if (!s->bucket->get_info().has_website) {
       // TODO-FUTURE: if the bucket has no WebsiteConfig, expose it here
index 3468584b169518150f6851f1b9e6af6dde6b1476..f78008de3a95f95b190cea082ef13fcb3115e2dc 100644 (file)
@@ -1458,8 +1458,8 @@ void RGWCopyObj_ObjStore_SWIFT::send_response()
     dump_etag(s, etag);
     dump_last_modified(s, mtime);
     dump_copy_info();
-    get_contype_from_attrs(attrs.attrs, content_type);
-    dump_object_metadata(this, s, attrs.attrs);
+    get_contype_from_attrs(attrs, content_type);
+    dump_object_metadata(this, s, attrs);
     end_header(s, this, !content_type.empty() ? content_type.c_str()
               : "binary/octet-stream");
   } else {
@@ -1554,8 +1554,8 @@ int RGWGetObj_ObjStore_SWIFT::send_response_data(bufferlist& bl,
       }
     }
 
-    get_contype_from_attrs(attrs.attrs, content_type);
-    dump_object_metadata(this, s, attrs.attrs);
+    get_contype_from_attrs(attrs, content_type);
+    dump_object_metadata(this, s, attrs);
   }
 
   end_header(s, this, !content_type.empty() ? content_type.c_str()
index a0e7b914ea098bc974c1fd3a76dfb2281546ea0d..3344f8a72e796eef95ebbc42c044dcfc59ab7dc4 100644 (file)
@@ -37,36 +37,7 @@ enum AttrsMod {
   ATTRSMOD_MERGE   = 2
 };
 
-struct RGWAttrs {
-  std::map<std::string, ceph::buffer::list> attrs;
-
-  RGWAttrs() {}
-  RGWAttrs(const std::map<std::string, ceph::buffer::list>&& _a) : attrs(std::move(_a)) {}
-  RGWAttrs(const std::map<std::string, ceph::buffer::list>& _a) : attrs(_a) {}
-
-  void emplace(std::string&& key, buffer::list&& bl) {
-    attrs.emplace(std::move(key), std::move(bl)); /* key and bl are r-value refs */
-    map<string, bufferlist>::iterator find(const std::string& key);
-  }
-  std::size_t erase(const std::string& key) {
-    return attrs.erase(key);
-  }
-  std::map<std::string, bufferlist>::iterator find(const std::string& key) {
-    return attrs.find(key);
-  }
-  std::map<std::string, bufferlist>::iterator end() {
-    return attrs.end();
-  }
-  std::map<std::string, bufferlist>::iterator begin() {
-    return attrs.begin();
-  }
-  ceph::buffer::list& operator[](const std::string& k) {
-    return attrs[k];
-  }
-  ceph::buffer::list& operator[](std::string&& k) {
-    return attrs[k];
-  }
-};
+using RGWAttrs = std::map<std::string, ceph::buffer::list>;
 
 class RGWStore : public DoutPrefixProvider {
   public:
@@ -83,7 +54,7 @@ class RGWStore : public DoutPrefixProvider {
                             rgw_placement_rule& placement_rule,
                             std::string& swift_ver_location,
                             const RGWQuotaInfo * pquota_info,
-                           map<std::string, bufferlist>& attrs,
+                           RGWAttrs& attrs,
                             RGWBucketInfo& info,
                             obj_version& ep_objv,
                            bool exclusive,
@@ -434,7 +405,7 @@ class RGWObject {
     /* OMAP */
     virtual int omap_get_vals_by_keys(const std::string& oid,
                              const std::set<std::string>& keys,
-                             std::map<std::string, bufferlist> *vals) = 0;
+                             RGWAttrs *vals) = 0;
 
     static bool empty(RGWObject* o) { return (!o || o->empty()); }
     virtual std::unique_ptr<RGWObject> clone() = 0;
index 601f03f699e681fed1d532dd2c71275867e5c75a..2e75b3e1a101533b19e422ddf0a0937a6d0497b8 100644 (file)
@@ -174,7 +174,7 @@ int RGWRadosBucket::get_bucket_info(optional_yield y)
   int ret = store->ctl()->bucket->read_bucket_info(info.bucket, &info, y,
                                      RGWBucketCtl::BucketInstance::GetParams()
                                      .set_mtime(&mtime)
-                                     .set_attrs(&attrs.attrs)
+                                     .set_attrs(&attrs)
                                       .set_bectx_params(bectx_params),
                                      &ep_ot);
   if (ret == 0) {
@@ -195,7 +195,7 @@ int RGWRadosBucket::load_by_name(const std::string& tenant, const std::string& b
     return get_bucket_info(y);
   }
 
-  return store->getRados()->get_bucket_instance_info(*rctx, info.bucket, info, NULL, &attrs.attrs, y);
+  return store->getRados()->get_bucket_instance_info(*rctx, info.bucket, info, NULL, &attrs, y);
 }
 
 int RGWRadosBucket::get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id,
@@ -258,7 +258,7 @@ int RGWRadosBucket::link(RGWUser* new_user, optional_yield y)
   ep.owner = new_user->get_user();
   ep.creation_time = get_creation_time();
   ep.linked = true;
-  map<string, bufferlist> ep_attrs;
+  RGWAttrs ep_attrs;
   rgw_ep_info ep_data{ep, ep_attrs};
 
   return store->ctl()->bucket->link_bucket(new_user->get_user(), info.bucket,
@@ -281,7 +281,7 @@ int RGWRadosBucket::chown(RGWUser* new_user, RGWUser* old_user, optional_yield y
 int RGWRadosBucket::put_instance_info(bool exclusive, ceph::real_time _mtime)
 {
   mtime = _mtime;
-  return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs.attrs);
+  return store->getRados()->put_bucket_instance_info(info, exclusive, mtime, &attrs);
 }
 
 /* Make sure to call get_bucket_info() if you need it first */
@@ -304,12 +304,12 @@ int RGWRadosBucket::check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_q
 int RGWRadosBucket::set_instance_attrs(RGWAttrs& attrs, optional_yield y)
 {
     return store->ctl()->bucket->set_bucket_instance_attrs(get_info(),
-                               attrs.attrs, &get_info().objv_tracker, y);
+                               attrs, &get_info().objv_tracker, y);
 }
 
 int RGWRadosBucket::try_refresh_info(ceph::real_time *pmtime)
 {
-  return store->getRados()->try_refresh_bucket_info(info, pmtime, &attrs.attrs);
+  return store->getRados()->try_refresh_bucket_info(info, pmtime, &attrs);
 }
 
 int RGWRadosBucket::set_acl(RGWAccessControlPolicy &acl, optional_yield y)
@@ -401,7 +401,7 @@ int RGWRadosObject::get_obj_state(RGWObjectCtx *rctx, RGWBucket& bucket, RGWObjS
 
 int RGWRadosObject::read_attrs(RGWRados::Object::Read &read_op, optional_yield y, rgw_obj *target_obj)
 {
-  read_op.params.attrs = &attrs.attrs;
+  read_op.params.attrs = &attrs;
   read_op.params.target_obj = target_obj;
   read_op.params.obj_size = &obj_size;
   read_op.params.lastmod = &mtime;
@@ -411,7 +411,7 @@ int RGWRadosObject::read_attrs(RGWRados::Object::Read &read_op, optional_yield y
 
 int RGWRadosObject::set_obj_attrs(RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAttrs* delattrs, optional_yield y, rgw_obj* target_obj)
 {
-  map<string, bufferlist> empty;
+  RGWAttrs empty;
   rgw_obj target = get_obj();
 
   if (!target_obj)
@@ -420,8 +420,8 @@ int RGWRadosObject::set_obj_attrs(RGWObjectCtx* rctx, RGWAttrs* setattrs, RGWAtt
   return store->getRados()->set_attrs(rctx,
                        bucket->get_info(),
                        *target_obj,
-                       setattrs ? setattrs->attrs : empty,
-                       delattrs ? &delattrs->attrs : nullptr,
+                       setattrs ? *setattrs : empty,
+                       delattrs ? delattrs : nullptr,
                        y);
 }
 
@@ -441,7 +441,7 @@ int RGWRadosObject::modify_obj_attrs(RGWObjectCtx *rctx, const char *attr_name,
     return r;
   }
   set_atomic(rctx);
-  attrs.attrs[attr_name] = attr_val;
+  attrs[attr_name] = attr_val;
   return set_obj_attrs(rctx, &attrs, nullptr, y, &target);
 }
 
@@ -451,7 +451,7 @@ int RGWRadosObject::delete_obj_attrs(RGWObjectCtx *rctx, const char *attr_name,
   bufferlist bl;
 
   set_atomic(rctx);
-  rmattr.attrs[attr_name] = bl;
+  rmattr[attr_name] = bl;
   return set_obj_attrs(rctx, nullptr, &rmattr, y);
 }
 
@@ -462,7 +462,7 @@ int RGWRadosObject::copy_obj_data(RGWObjectCtx& rctx, RGWBucket* dest_bucket,
                                  const DoutPrefixProvider *dpp,
                                  optional_yield y)
 {
-  map<string, bufferlist> attrset;
+  RGWAttrs attrset;
   RGWRados::Object op_target(store->getRados(), dest_bucket->get_info(), rctx, get_obj());
   RGWRados::Object::Read read_op(&op_target);
 
@@ -470,7 +470,7 @@ int RGWRadosObject::copy_obj_data(RGWObjectCtx& rctx, RGWBucket* dest_bucket,
   if (ret < 0)
     return ret;
 
-  attrset = attrs.attrs;
+  attrset = attrs;
 
   attrset.erase(RGW_ATTR_ID_TAG);
   attrset.erase(RGW_ATTR_TAIL_TAG);
@@ -494,7 +494,7 @@ void RGWRadosObject::set_prefetch_data(RGWObjectCtx *rctx)
 }
 
 bool RGWRadosObject::is_expired() {
-  map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_DELETE_AT);
+  auto iter = attrs.find(RGW_ATTR_DELETE_AT);
   if (iter != attrs.end()) {
     utime_t delete_at;
     try {
@@ -520,7 +520,7 @@ void RGWRadosObject::gen_rand_obj_instance_name()
 
 int RGWRadosObject::omap_get_vals_by_keys(const std::string& oid,
                                          const std::set<std::string>& keys,
-                                         std::map<std::string, bufferlist> *vals)
+                                         RGWAttrs *vals)
 {
   int ret;
   rgw_raw_obj head_obj;
@@ -565,7 +565,7 @@ int RGWRadosObject::RadosReadOp::prepare(optional_yield y)
   parent_op.params.lastmod = params.lastmod;
   parent_op.params.target_obj = params.target_obj;
   parent_op.params.obj_size = &obj_size;
-  parent_op.params.attrs = &source->get_attrs().attrs;
+  parent_op.params.attrs = &source->get_attrs();
 
   int ret = parent_op.prepare(y);
   if (ret < 0)
@@ -664,7 +664,7 @@ int RGWRadosObject::copy_object(RGWObjectCtx& obj_ctx,
                                     if_nomatch,
                                     static_cast<RGWRados::AttrsMod>(attrs_mod),
                                     copy_if_newer,
-                                    attrs.attrs,
+                                    attrs,
                                     category,
                                     olh_epoch,
                                     (delete_at ? *delete_at : real_time()),
@@ -741,10 +741,10 @@ static int decode_policy(CephContext *cct,
 
 static int rgw_op_get_bucket_policy_from_attr(RGWRadosStore *store,
                                       RGWUser& user,
-                                      map<string, bufferlist>& bucket_attrs,
+                                      RGWAttrs& bucket_attrs,
                                       RGWAccessControlPolicy *policy)
 {
-  map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL);
+  auto aiter = bucket_attrs.find(RGW_ATTR_ACL);
 
   if (aiter != bucket_attrs.end()) {
     int ret = decode_policy(store->ctx(), aiter->second, policy);
@@ -819,7 +819,7 @@ int RGWRadosStore::create_bucket(RGWUser& u, const rgw_bucket& b,
                                 rgw_placement_rule& placement_rule,
                                 string& swift_ver_location,
                                 const RGWQuotaInfo * pquota_info,
-                                map<std::string, bufferlist>& attrs,
+                                RGWAttrs& attrs,
                                 RGWBucketInfo& info,
                                 obj_version& ep_objv,
                                 bool exclusive,
@@ -849,7 +849,7 @@ int RGWRadosStore::create_bucket(RGWUser& u, const rgw_bucket& b,
       swift_ver_location = bucket->get_info().swift_ver_location;
     }
     placement_rule.inherit_from(bucket->get_info().placement_rule);
-    int r = rgw_op_get_bucket_policy_from_attr(this, u, bucket->get_attrs().attrs,
+    int r = rgw_op_get_bucket_policy_from_attr(this, u, bucket->get_attrs(),
                                               &old_policy);
     if (r >= 0)  {
       if (old_policy.get_owner().get_id().compare(u.get_id()) != 0) {
index c43d4b7b56029552eef12b4e044095fb376a28e6..5f0253f5c016a5717910e01d9149fc37955089f3 100644 (file)
@@ -124,7 +124,7 @@ class RGWRadosObject : public RGWObject {
     /* OMAP */
     virtual int omap_get_vals_by_keys(const std::string& oid,
                              const std::set<std::string>& keys,
-                             std::map<std::string, bufferlist> *vals) override;
+                             RGWAttrs *vals) override;
 
   private:
     int read_attrs(RGWRados::Object::Read &read_op, optional_yield y, rgw_obj *target_obj = nullptr);
@@ -236,7 +236,7 @@ class RGWRadosStore : public RGWStore {
                             rgw_placement_rule& placement_rule,
                             std::string& swift_ver_location,
                             const RGWQuotaInfo * pquota_info,
-                           map<std::string, bufferlist>& attrs,
+                           RGWAttrs& attrs,
                             RGWBucketInfo& info,
                             obj_version& ep_objv,
                            bool exclusive,