]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: ONLY refactor handling the RGWUserInfo update in RGWPutMetadataAccount.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 10 May 2016 11:26:08 +0000 (13:26 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 30 May 2016 09:42:56 +0000 (11:42 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h

index 99297c9038b59abf40660f17ff49ac3a99e29f85..8e55b7635e0f92af53dfb164b7332bd8c5a2388c 100644 (file)
@@ -2797,34 +2797,6 @@ done:
   dispose_processor(processor);
 }
 
-int RGWPutMetadataAccount::handle_temp_url_update(
-  const map<int, string>& temp_url_keys) {
-  RGWUserAdminOpState user_op;
-  user_op.set_user_id(s->user->user_id);
-
-  map<int, string>::const_iterator iter;
-  for (iter = temp_url_keys.begin(); iter != temp_url_keys.end(); ++iter) {
-    user_op.set_temp_url_key(iter->second, iter->first);
-  }
-
-  RGWUser user;
-  op_ret = user.init(store, user_op);
-  if (op_ret < 0) {
-    ldout(store->ctx(), 0) << "ERROR: could not init user ret=" << op_ret
-                          << dendl;
-    return op_ret;
-  }
-
-  string err_msg;
-  op_ret = user.modify(user_op, &err_msg);
-  if (op_ret < 0) {
-    ldout(store->ctx(), 10) << "user.modify() returned " << op_ret << ": "
-                           << err_msg << dendl;
-    return op_ret;
-  }
-  return 0;
-}
-
 int RGWPutMetadataAccount::verify_permission()
 {
   if (!rgw_user_is_authenticated(*(s->user))) {
@@ -2887,36 +2859,31 @@ void RGWPutMetadataAccount::execute()
   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,
+  RGWUserInfo new_uinfo;
+  op_ret = rgw_get_user_info_by_uid(store, s->user->user_id, new_uinfo,
                                     &acct_op_tracker);
   if (op_ret < 0) {
     return;
   }
 
   /* Handle the TempURL-related stuff. */
-  map<int, string> temp_url_keys;
+  std::map<int, std::string> temp_url_keys;
   filter_out_temp_url(attrs, rmattr_names, temp_url_keys);
   if (!temp_url_keys.empty()) {
     if (s->perm_mask != RGW_PERM_FULL_CONTROL) {
       op_ret = -EPERM;
       return;
     }
-  }
-
-  /* XXX tenant needed? */
-  op_ret = rgw_store_user_info(store, *(s->user), &orig_uinfo,
-                               &acct_op_tracker, real_time(), false, &attrs);
-  if (op_ret < 0) {
-    return;
-  }
 
-  if (!temp_url_keys.empty()) {
-    op_ret = handle_temp_url_update(temp_url_keys);
-    if (op_ret < 0) {
-      return;
+    for (auto& pair : temp_url_keys) {
+      new_uinfo.temp_url_keys[pair.first] = std::move(pair.second);
     }
   }
+
+  /* We are passing here the current (old) user info to allow the function
+   * optimize-out some operations. */
+  op_ret = rgw_store_user_info(store, new_uinfo, s->user,
+                               &acct_op_tracker, real_time(), false, &attrs);
 }
 
 int RGWPutMetadataBucket::verify_permission()
index a5ac5563192cb1076df6fece3ce6f6621922aea7..249e2f180577b1b5e938372b66930b9771ca068d 100644 (file)
@@ -764,7 +764,6 @@ public:
   virtual void filter_out_temp_url(map<string, bufferlist>& add_attrs,
                                    const set<string>& rmattr_names,
                                    map<int, string>& temp_url_keys);
-  virtual int handle_temp_url_update(const map<int, string>& temp_url_keys);
   virtual const string name() { return "put_account_metadata"; }
   virtual RGWOpType get_type() { return RGW_OP_PUT_METADATA_ACCOUNT; }
   virtual uint32_t op_mask() { return RGW_OP_TYPE_WRITE; }