From: Matt Benjamin Date: Tue, 12 Apr 2016 02:01:30 +0000 (-0400) Subject: rgw_file: use emplace_attr in RGWPostObj and RGWPutMetadataBucket X-Git-Tag: v10.2.0~8^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7a7de9b75265b978ba4e53966f614fac033972cb;p=ceph.git rgw_file: use emplace_attr in RGWPostObj and RGWPutMetadataBucket Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index fffd4cd17615..ae4db4031bf6 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2606,7 +2606,7 @@ void RGWPostObj::execute() char calc_md5[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1]; unsigned char m[CEPH_CRYPTO_MD5_DIGESTSIZE]; MD5 hash; - bufferlist bl, aclbl; + buffer::list bl, aclbl; int len = 0; // read in the data from the POST form @@ -2674,17 +2674,17 @@ void RGWPostObj::execute() hash.Final(m); buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5); - policy.encode(aclbl); etag = calc_md5; - bl.append(etag.c_str(), etag.size() + 1); - attrs[RGW_ATTR_ETAG] = bl; - attrs[RGW_ATTR_ACL] = aclbl; + emplace_attr(RGW_ATTR_ETAG, std::move(bl)); + + policy.encode(aclbl); + emplace_attr(RGW_ATTR_ACL, std::move(aclbl)); if (content_type.size()) { bufferlist ct_bl; ct_bl.append(content_type.c_str(), content_type.size() + 1); - attrs[RGW_ATTR_CONTENT_TYPE] = ct_bl; + emplace_attr(RGW_ATTR_CONTENT_TYPE, std::move(ct_bl)); } op_ret = processor->complete(etag, NULL, real_time(), attrs, delete_at); @@ -2819,7 +2819,7 @@ void RGWPutMetadataBucket::pre_exec() void RGWPutMetadataBucket::execute() { - map attrs, orig_attrs; + map orig_attrs; op_ret = get_params(); if (op_ret < 0) { @@ -2834,26 +2834,27 @@ void RGWPutMetadataBucket::execute() return; } - orig_attrs = s->bucket_attrs; + orig_attrs = s->bucket_attrs; /* XXX map copy */ prepare_add_del_attrs(orig_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); if (has_policy) { - bufferlist bl; + buffer::list bl; policy.encode(bl); - attrs[RGW_ATTR_ACL] = bl; + emplace_attr(RGW_ATTR_ACL, std::move(bl)); } if (has_cors) { - bufferlist bl; + buffer::list bl; cors_config.encode(bl); - attrs[RGW_ATTR_CORS] = bl; + emplace_attr(RGW_ATTR_CORS, std::move(bl)); } s->bucket_info.swift_ver_location = swift_ver_location; s->bucket_info.swift_versioning = (!swift_ver_location.empty()); - op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); + op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, + &s->bucket_info.objv_tracker); } int RGWPutMetadataObject::verify_permission() diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 1bda388c6396..ed1b9e335ddf 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -717,6 +717,10 @@ public: supplied_md5_b64(NULL), supplied_etag(NULL), data_pending(false) {} + 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); policy.set_ctx(s->cct); @@ -766,6 +770,7 @@ public: class RGWPutMetadataBucket : public RGWOp { protected: + map attrs; set rmattr_names; bool has_policy, has_cors; RGWAccessControlPolicy policy; @@ -778,10 +783,15 @@ public: : has_policy(false), has_cors(false) {} + 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); policy.set_ctx(s->cct); } + int verify_permission(); void pre_exec(); void execute();