From ff2af15ddce920a1ced37a139f499b56ff5e9f6b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 26 Apr 2019 12:38:48 -0700 Subject: [PATCH] rgw: svc_user adjustments Signed-off-by: Yehuda Sadeh --- src/rgw/services/svc_user.cc | 25 ++++---- src/rgw/services/svc_user.h | 108 ----------------------------------- 2 files changed, 11 insertions(+), 122 deletions(-) diff --git a/src/rgw/services/svc_user.cc b/src/rgw/services/svc_user.cc index aa076f03f33..096d5c1067d 100644 --- a/src/rgw/services/svc_user.cc +++ b/src/rgw/services/svc_user.cc @@ -130,14 +130,13 @@ public: } } - map::iterator iter; - for (iter = info.swift_keys.begin(); iter != info.swift_keys.end(); ++iter) { + for (auto iter = info.swift_keys.begin(); iter != info.swift_keys.end(); ++iter) { if (old_info && old_info->swift_keys.count(iter->first) != 0) continue; - RGWAccessKey& k = iter->second; + auto& k = iter->second; /* check if swift mapping exists */ RGWUserInfo inf; - int r = svc.user->get_user_info_by_swift(ctx, k.id, inf, nullptr, nullptr); + int r = svc.user->get_user_info_by_swift(ctx, k.id, &inf, nullptr, nullptr); if (r >= 0 && inf.user_id != info.user_id) { ldout(svc.meta_be->ctx(), 0) << "WARNING: can't store user info, swift id (" << k.id << ") already mapped to another user (" << info.user_id << ")" << dendl; @@ -149,7 +148,7 @@ public: for (auto iter = info.access_keys.begin(); iter != info.access_keys.end(); ++iter) { if (old_info && old_info->access_keys.count(iter->first) != 0) continue; - RGWAccessKey& k = iter->second; + auto& k = iter->second; RGWUserInfo inf; int r = svc.user->get_user_info_by_access_key(ctx, k.id, &inf, nullptr, nullptr, y); if (r >= 0 && inf.user_id != info.user_id) { @@ -194,7 +193,7 @@ public: } for (auto iter = info.access_keys.begin(); iter != info.access_keys.end(); ++iter) { - RGWAccessKey& k = iter->second; + auto& k = iter->second; if (old_info && old_info->access_keys.count(iter->first) != 0) continue; @@ -204,9 +203,8 @@ public: return ret; } - map::iterator siter; - for (siter = info.swift_keys.begin(); siter != info.swift_keys.end(); ++siter) { - RGWAccessKey& k = siter->second; + for (auto siter = info.swift_keys.begin(); siter != info.swift_keys.end(); ++siter) { + auto& k = siter->second; if (old_info && old_info->swift_keys.count(siter->first) != 0) continue; @@ -226,7 +224,7 @@ public: return 0; } - int remove_old_indexes(RGWUserInfo& old_info, RGWUserInfo& new_info, optional_yield y) { + int remove_old_indexes(const RGWUserInfo& old_info, const RGWUserInfo& new_info, optional_yield y) { int ret; if (!old_info.user_id.empty() && @@ -251,10 +249,9 @@ public: } } - map::iterator old_iter; - for (old_iter = old_info.swift_keys.begin(); old_iter != old_info.swift_keys.end(); ++old_iter) { - RGWAccessKey& swift_key = old_iter->second; - map::iterator new_iter = new_info.swift_keys.find(swift_key.id); + for (auto old_iter = old_info.swift_keys.begin(); old_iter != old_info.swift_keys.end(); ++old_iter) { + const auto& swift_key = old_iter->second; + auto new_iter = new_info.swift_keys.find(swift_key.id); if (new_iter == new_info.swift_keys.end()) { ret = svc.user->remove_swift_name_index(ctx, swift_key.id, y); if (ret < 0 && ret != -ENOENT) { diff --git a/src/rgw/services/svc_user.h b/src/rgw/services/svc_user.h index 3b1518cd701..144e40ffd36 100644 --- a/src/rgw/services/svc_user.h +++ b/src/rgw/services/svc_user.h @@ -91,114 +91,6 @@ public: return user_id.to_str() + RGW_BUCKETS_OID_SUFFIX; } -#if 0 - class User { - friend class Op; - - RGWSI_User::Svc& svc; - RGWSysObjectCtx& ctx; - rgw_user user; - RGWUserInfo user_info; - - public: - User(RGWSI_User *_user_svc, - RGWSysObjectCtx& _ctx, - const rgw_user& _user) : svc(_user_svc->svc), - ctx(_ctx), user(_user) {} - - RGWSysObjectCtx& get_ctx() { - return ctx; - } - - rgw_user& get_user() { - return user; - } - - RGWUserInfo& get_user_info() { - return user_info; - } - - struct GetOp { - User& source; - - ceph::real_time *pmtime{nullptr}; - map *pattrs{nullptr}; - RGWUserInfo *pinfo{nullptr}; - RGWObjVersionTracker *objv_tracker{nullptr}; - - - GetOp& set_mtime(ceph::real_time *_mtime) { - pmtime = _mtime; - return *this; - } - - GetOp& set_attrs(map *_attrs) { - pattrs = _attrs; - return *this; - } - - GetOp& set_pinfo(RGWUserInfo *_pinfo) { - pinfo = _pinfo; - return *this; - } - - GetOp& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { - objv_tracker = _objv_tracker; - return *this; - } - - GetOp(User& _source) : source(_source) {} - - int exec(); - }; - - struct SetOp { - User& source; - - ceph::real_time mtime; - map *pattrs{nullptr}; - bool exclusive{false}; - RGWUserInfo *old_info{nullptr}; - - - SetOp& set_mtime(const ceph::real_time& _mtime) { - mtime = _mtime; - return *this; - } - - SetOp& set_attrs(map *_attrs) { - pattrs = _attrs; - return *this; - } - - SetOp& set_exclusive(bool _exclusive) { - exclusive = _exclusive; - return *this; - } - - SetOp& set_old_info(RGWUserInfo *_old_info) { - old_info = _old_info; - return *this; - } - - SetOp(User& _source) : source(_source) {} - - int exec(); - }; - - GetOp get_op() { - return GetOp(*this); - } - - SetOp set_op() { - return SetOp(*this); - } - }; - - User user(RGWSysObjectCtx& _ctx, - const rgw_user& _user); -#endif - /* base svc_user interfaces */ int read_user_info(RGWSI_MetaBackend::Context *ctx, -- 2.39.5