]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: use emplace_attr in RGWCreateBucket and RGWCopyObj
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 04:33:21 +0000 (00:33 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 20:12:33 +0000 (16:12 -0400)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h

index ae4db4031bf67c0ea373126626443dcd8171acaa..d0508213069b752e09bcab0388cf2b97b071a566 100644 (file)
@@ -1879,9 +1879,8 @@ static void populate_with_generic_attrs(const req_state * const s,
 void RGWCreateBucket::execute()
 {
   RGWAccessControlPolicy old_policy(s->cct);
-  map<string, bufferlist> attrs;
-  bufferlist aclbl;
-  bufferlist corsbl;
+  buffer::list aclbl;
+  buffer::list corsbl;
   bool existed;
   string bucket_name;
   rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name, bucket_name);
@@ -1974,17 +1973,17 @@ void RGWCreateBucket::execute()
   }
 
   policy.encode(aclbl);
-  attrs[RGW_ATTR_ACL] = aclbl;
+  emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
 
   if (has_cors) {
     cors_config.encode(corsbl);
-    attrs[RGW_ATTR_CORS] = corsbl;
+    emplace_attr(RGW_ATTR_CORS, std::move(corsbl));
   }
   s->bucket.tenant = s->bucket_tenant; /* ignored if bucket exists */
   s->bucket.name = s->bucket_name;
-  op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id, placement_rule,
-                                swift_ver_location,
-                               attrs, info, pobjv, &ep_objv, creation_time,
+  op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id,
+                               placement_rule, swift_ver_location, attrs,
+                               info, pobjv, &ep_objv, creation_time,
                                pmaster_bucket, true);
   /* continue if EEXIST and create_bucket will fail below.  this way we can
    * recover from a partial create by retrying it. */
@@ -3219,8 +3218,8 @@ int RGWCopyObj::init_common()
 
   bufferlist aclbl;
   dest_policy.encode(aclbl);
+  emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
 
-  attrs[RGW_ATTR_ACL] = aclbl;
   rgw_get_request_metadata(s->cct, s->info, attrs);
 
   map<string, string>::iterator iter;
index ed1b9e335ddf80c2fd7a1fd6a4d09892336227f9..b96147994235b08c8e4dbe7d6aa4109bbaef364c 100644 (file)
@@ -536,6 +536,7 @@ protected:
   bool has_cors;
   RGWCORSConfiguration cors_config;
   string swift_ver_location;
+  map<string, buffer::list> attrs;
   set<string> rmattr_names;
 
   bufferlist in_data;
@@ -545,6 +546,10 @@ protected:
 public:
   RGWCreateBucket() : has_cors(false) {}
 
+  void emplace_attr(std::string&& key, buffer::list&& bl) {
+    attrs.emplace(key, bl); /* key and bl are r-value refs */
+  }
+
   int verify_permission();
   void pre_exec();
   void execute();
@@ -875,7 +880,7 @@ protected:
   ceph::real_time unmod_time;
   ceph::real_time *mod_ptr;
   ceph::real_time *unmod_ptr;
-  map<string, bufferlist> attrs;
+  map<string, buffer::list> attrs;
   string src_tenant_name, src_bucket_name;
   rgw_bucket src_bucket;
   rgw_obj_key src_object;
@@ -923,6 +928,10 @@ public:
                                   string& bucket_name,
                                   rgw_obj_key& object);
 
+  void emplace_attr(std::string&& key, buffer::list&& bl) {
+    attrs.emplace(key, bl); /* key and bl are r-value refs */
+  }
+
   virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) {
     RGWOp::init(store, s, h);
     dest_policy.set_ctx(s->cct);