From 30ee18018ae890a058ae40a6006e1045258d36d5 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 9 May 2016 17:22:45 +0200 Subject: [PATCH 1/2] rgw: fix updating account/container metadata of Swift API. This patch rectifies an issue with handling of user metadata that are actually stored by an updated resource (account or container). The expected behaviour is they will be merged with new medadata coming from an HTTP client. Backport: Jewel Fixes: http://tracker.ceph.com/issues/15779 Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 3f3b18bff16f6a5b36987f888ba3f2a0d1ea3155) --- src/rgw/rgw_op.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a2202caf07518..30764799a76f4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1856,6 +1856,8 @@ static void prepare_add_del_attrs(const map& orig_attrs, if (aiter != std::end(out_attrs)) { out_attrs.erase(aiter); } + } else { + out_attrs[name] = kv.second; } } else if (out_attrs.find(name) == std::end(out_attrs)) { out_attrs[name] = kv.second; @@ -2773,11 +2775,23 @@ void RGWPutMetadataAccount::execute() return; } + op_ret = rgw_get_user_attrs_by_uid(store, s->user->user_id, orig_attrs, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + rgw_get_request_metadata(s->cct, s->info, attrs, false); - RGWUserInfo orig_uinfo; - rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, &acct_op_tracker); + prepare_add_del_attrs(orig_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); + RGWUserInfo orig_uinfo; + op_ret = rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + /* Handle the TempURL-related stuff. */ map temp_url_keys; filter_out_temp_url(attrs, rmattr_names, temp_url_keys); From 4eded9aa94384e60e765accb4c9f093bd2534970 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sat, 21 May 2016 02:47:12 +0200 Subject: [PATCH 2/2] rgw: fix update of already existing account/bucket's custom attributes. Introduced in: 3f3b18bff16f6a5b36987f888ba3f2a0d1ea3155. Fixes: http://tracker.ceph.com/issues/15977 Signed-off-by: Radoslaw Zarzynski (cherry picked from commit d6129e664fc8d25e70bfaf83e340703005f8f73f) --- src/rgw/rgw_op.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 30764799a76f4..0c22e894fadef 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1857,7 +1857,9 @@ static void prepare_add_del_attrs(const map& orig_attrs, out_attrs.erase(aiter); } } else { - out_attrs[name] = kv.second; + /* emplace() won't alter the map if the key is already present. + * This behaviour is fully intensional here. */ + out_attrs.emplace(kv); } } else if (out_attrs.find(name) == std::end(out_attrs)) { out_attrs[name] = kv.second;