rgw_file: use emplace_attr in RGWCreateBucket and RGWCopyObj

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
Matt Benjamin 2016-04-12 00:33:21 -04:00
parent 7a7de9b752
commit 601b193874
2 changed files with 18 additions and 10 deletions

View File

@ -1879,9 +1879,8 @@ static void populate_with_generic_attrs(const req_state * const s,
void RGWCreateBucket::execute() void RGWCreateBucket::execute()
{ {
RGWAccessControlPolicy old_policy(s->cct); RGWAccessControlPolicy old_policy(s->cct);
map<string, bufferlist> attrs; buffer::list aclbl;
bufferlist aclbl; buffer::list corsbl;
bufferlist corsbl;
bool existed; bool existed;
string bucket_name; string bucket_name;
rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name, 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); policy.encode(aclbl);
attrs[RGW_ATTR_ACL] = aclbl; emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
if (has_cors) { if (has_cors) {
cors_config.encode(corsbl); 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.tenant = s->bucket_tenant; /* ignored if bucket exists */
s->bucket.name = s->bucket_name; s->bucket.name = s->bucket_name;
op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id, placement_rule, op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id,
swift_ver_location, placement_rule, swift_ver_location, attrs,
attrs, info, pobjv, &ep_objv, creation_time, info, pobjv, &ep_objv, creation_time,
pmaster_bucket, true); pmaster_bucket, true);
/* continue if EEXIST and create_bucket will fail below. this way we can /* continue if EEXIST and create_bucket will fail below. this way we can
* recover from a partial create by retrying it. */ * recover from a partial create by retrying it. */
@ -3219,8 +3218,8 @@ int RGWCopyObj::init_common()
bufferlist aclbl; bufferlist aclbl;
dest_policy.encode(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); rgw_get_request_metadata(s->cct, s->info, attrs);
map<string, string>::iterator iter; map<string, string>::iterator iter;

View File

@ -536,6 +536,7 @@ protected:
bool has_cors; bool has_cors;
RGWCORSConfiguration cors_config; RGWCORSConfiguration cors_config;
string swift_ver_location; string swift_ver_location;
map<string, buffer::list> attrs;
set<string> rmattr_names; set<string> rmattr_names;
bufferlist in_data; bufferlist in_data;
@ -545,6 +546,10 @@ protected:
public: public:
RGWCreateBucket() : has_cors(false) {} 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(); int verify_permission();
void pre_exec(); void pre_exec();
void execute(); void execute();
@ -875,7 +880,7 @@ protected:
ceph::real_time unmod_time; ceph::real_time unmod_time;
ceph::real_time *mod_ptr; ceph::real_time *mod_ptr;
ceph::real_time *unmod_ptr; ceph::real_time *unmod_ptr;
map<string, bufferlist> attrs; map<string, buffer::list> attrs;
string src_tenant_name, src_bucket_name; string src_tenant_name, src_bucket_name;
rgw_bucket src_bucket; rgw_bucket src_bucket;
rgw_obj_key src_object; rgw_obj_key src_object;
@ -923,6 +928,10 @@ public:
string& bucket_name, string& bucket_name,
rgw_obj_key& object); 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) { virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) {
RGWOp::init(store, s, h); RGWOp::init(store, s, h);
dest_policy.set_ctx(s->cct); dest_policy.set_ctx(s->cct);