diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index ae4db4031bf..d0508213069 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1879,9 +1879,8 @@ static void populate_with_generic_attrs(const req_state * const s, void RGWCreateBucket::execute() { RGWAccessControlPolicy old_policy(s->cct); - map 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::iterator iter; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index ed1b9e335dd..b9614799423 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -536,6 +536,7 @@ protected: bool has_cors; RGWCORSConfiguration cors_config; string swift_ver_location; + map attrs; set 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 attrs; + map 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);