From 82ea02ab8d886c16c511c4bd7d03d826158f954b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 17 Jun 2015 11:35:18 -0700 Subject: [PATCH] rgw: fix assignment of copy obj attributes Fixes: #11563 Clarify the confusing usage of set_copy_attrs() by switching the source and destinatiion params (attrs, src_attrs). Switch to use attrs instead of src_attrs afterwards. In one of the cases we originally used the wrong variable. Signed-off-by: Yehuda Sadeh (cherry picked from commit e41d97c8e38bb60d7e09e9801c0179efe7af1734) --- src/rgw/rgw_rados.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e71f6a2a6516..f4994f5e7bde 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3698,17 +3698,18 @@ static void set_copy_attrs(map& src_attrs, { switch (attrs_mod) { case RGWRados::ATTRSMOD_NONE: - src_attrs[RGW_ATTR_ACL] = attrs[RGW_ATTR_ACL]; + attrs = src_attrs; break; case RGWRados::ATTRSMOD_REPLACE: if (!attrs[RGW_ATTR_ETAG].length()) { attrs[RGW_ATTR_ETAG] = src_attrs[RGW_ATTR_ETAG]; } - src_attrs = attrs; break; case RGWRados::ATTRSMOD_MERGE: - for (map::iterator it = attrs.begin(); it != attrs.end(); ++it) { - src_attrs[it->first] = it->second; + for (map::iterator it = src_attrs.begin(); it != src_attrs.end(); ++it) { + if (attrs.find(it->first) == attrs.end()) { + attrs[it->first] = it->second; + } } break; } @@ -3858,8 +3859,8 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, } if (petag) { - map::iterator iter = src_attrs.find(RGW_ATTR_ETAG); - if (iter != src_attrs.end()) { + map::iterator iter = attrs.find(RGW_ATTR_ETAG); + if (iter != attrs.end()) { bufferlist& etagbl = iter->second; *petag = string(etagbl.c_str(), etagbl.length()); } @@ -3869,7 +3870,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, set_copy_attrs(src_attrs, attrs, attrs_mod); } - ret = cb.complete(etag, mtime, set_mtime, src_attrs); + ret = cb.complete(etag, mtime, set_mtime, attrs); if (ret < 0) { goto set_err_state; } @@ -4007,7 +4008,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, } set_copy_attrs(src_attrs, attrs, attrs_mod); - src_attrs.erase(RGW_ATTR_ID_TAG); + attrs.erase(RGW_ATTR_ID_TAG); RGWObjManifest manifest; RGWObjState *astate = NULL; @@ -4020,7 +4021,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (remote_dest) { /* dest is in a different region, copy it there */ - return copy_obj_to_remote_dest(astate, src_attrs, read_op, user_id, dest_obj, mtime); + return copy_obj_to_remote_dest(astate, attrs, read_op, user_id, dest_obj, mtime); } uint64_t max_chunk_size; @@ -4058,7 +4059,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */ return copy_obj_data(obj_ctx, dest_bucket_info, read_op, end, dest_obj, src_obj, - max_chunk_size, mtime, 0, src_attrs, category, olh_epoch, + max_chunk_size, mtime, 0, attrs, category, olh_epoch, version_id, ptag, petag, err); } -- 2.47.3