Merge pull request #40967 from dang/wip-dang-zipper-user

RGW Zipper consistent load/store APIs for User
This commit is contained in:
Daniel Gryniewicz 2021-04-30 10:03:58 -04:00 committed by GitHub
commit 6110c687a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 101 additions and 122 deletions

View File

@ -682,7 +682,7 @@ namespace rgw {
const DoutPrefix dp(store->ctx(), dout_subsys, "librgw: ");
std::unique_ptr<rgw::sal::User> user = store->get_user(uid);
/* object exists, but policy is broken */
int ret = user->load_by_id(&dp, null_yield);
int ret = user->load_user(&dp, null_yield);
if (ret < 0) {
derr << "ERROR: failed reading user info: uid=" << uid << " ret="
<< ret << dendl;

View File

@ -313,7 +313,7 @@ static int parse_grantee_str(const DoutPrefixProvider *dpp, rgw::sal::Store* sto
grant.set_canon(user->get_id(), user->get_display_name(), rgw_perm);
} else if (strcasecmp(id_type.c_str(), "id") == 0) {
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(id_val));
ret = user->load_by_id(dpp, null_yield);
ret = user->load_user(dpp, null_yield);
if (ret < 0)
return ret;
@ -492,7 +492,7 @@ int RGWAccessControlPolicy_S3::rebuild(const DoutPrefixProvider *dpp,
}
std::unique_ptr<rgw::sal::User> user = store->get_user(owner->get_id());
if (user->load_by_id(dpp, null_yield) < 0) {
if (user->load_user(dpp, null_yield) < 0) {
ldout(cct, 10) << "owner info does not exist" << dendl;
err_msg = "Invalid id";
return -EINVAL;
@ -546,7 +546,7 @@ int RGWAccessControlPolicy_S3::rebuild(const DoutPrefixProvider *dpp,
if (grant_user.user_id.empty()) {
user = store->get_user(uid);
if (user->load_by_id(dpp, null_yield) < 0) {
if (user->load_user(dpp, null_yield) < 0) {
ldout(cct, 10) << "grant user does not exist:" << uid << dendl;
err_msg = "Invalid id";
return -EINVAL;

View File

@ -123,7 +123,7 @@ static ACLGrant user_to_grant(const DoutPrefixProvider *dpp,
std::unique_ptr<rgw::sal::User> user;
user = store->get_user(rgw_user(uid));
if (user->load_by_id(dpp, null_yield) < 0) {
if (user->load_user(dpp, null_yield) < 0) {
ldout(cct, 10) << "grant user does not exist: " << uid << dendl;
/* skipping silently */
grant.set_canon(user->get_id(), std::string(), perm);
@ -316,7 +316,7 @@ void RGWAccessControlPolicy_SWIFTAcct::add_grants(const DoutPrefixProvider *dpp,
} else {
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(uid));
if (user->load_by_id(dpp, null_yield) < 0) {
if (user->load_user(dpp, null_yield) < 0) {
ldout(cct, 10) << "grant user does not exist:" << uid << dendl;
/* skipping silently */
grant.set_canon(user->get_id(), std::string(), perm);

View File

@ -376,8 +376,7 @@ void rgw::auth::WebIdentityApplier::create_account(const DoutPrefixProvider* dpp
rgw_apply_default_bucket_quota(user->get_info().bucket_quota, cct->_conf);
rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
int ret = user->store_info(dpp, null_yield,
RGWUserCtl::PutParams().set_exclusive(true));
int ret = user->store_user(dpp, null_yield, true);
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: failed to store new user info: user="
<< user << " ret=" << ret << dendl;
@ -395,7 +394,7 @@ void rgw::auth::WebIdentityApplier::load_acct_info(const DoutPrefixProvider* dpp
std::unique_ptr<rgw::sal::User> user = store->get_user(federated_user);
//Check in oidc namespace
if (user->load_by_id(dpp, null_yield) >= 0) {
if (user->load_user(dpp, null_yield) >= 0) {
/* Succeeded. */
user_info = user->get_info();
return;
@ -403,7 +402,7 @@ void rgw::auth::WebIdentityApplier::load_acct_info(const DoutPrefixProvider* dpp
user->clear_ns();
//Check for old users which wouldn't have been created in oidc namespace
if (user->load_by_id(dpp, null_yield) >= 0) {
if (user->load_user(dpp, null_yield) >= 0) {
/* Succeeded. */
user_info = user->get_info();
return;
@ -603,8 +602,7 @@ void rgw::auth::RemoteApplier::create_account(const DoutPrefixProvider* dpp,
rgw_apply_default_user_quota(user->get_info().user_quota, cct->_conf);
user_info = user->get_info();
int ret = user->store_info(dpp, null_yield,
RGWUserCtl::PutParams().set_exclusive(true));
int ret = user->store_user(dpp, null_yield, true);
if (ret < 0) {
ldpp_dout(dpp, 0) << "ERROR: failed to store new user info: user="
<< user << " ret=" << ret << dendl;
@ -647,7 +645,7 @@ void rgw::auth::RemoteApplier::load_acct_info(const DoutPrefixProvider* dpp, RGW
const rgw_user tenanted_uid(acct_user.id, acct_user.id);
user = store->get_user(tenanted_uid);
if (user->load_by_id(dpp, null_yield) >= 0) {
if (user->load_user(dpp, null_yield) >= 0) {
/* Succeeded. */
user_info = user->get_info();
return;
@ -658,7 +656,7 @@ void rgw::auth::RemoteApplier::load_acct_info(const DoutPrefixProvider* dpp, RGW
if (split_mode && implicit_tenant)
; /* suppress lookup for id used by "other" protocol */
else if (user->load_by_id(dpp, null_yield) >= 0) {
else if (user->load_user(dpp, null_yield) >= 0) {
/* Succeeded. */
user_info = user->get_info();
return;

View File

@ -185,7 +185,7 @@ void ThirdPartyAccountApplier<T>::load_acct_info(const DoutPrefixProvider* dpp,
const rgw_user tenanted_uid(acct_user_override.id, acct_user_override.id);
user = store->get_user(tenanted_uid);
if (user->load_by_id(dpp, null_yield) >= 0) {
if (user->load_user(dpp, null_yield) >= 0) {
user_info = user->get_info();
/* Succeeded. */
return;
@ -193,7 +193,7 @@ void ThirdPartyAccountApplier<T>::load_acct_info(const DoutPrefixProvider* dpp,
}
user = store->get_user(acct_user_override);
const int ret = user->load_by_id(dpp, null_yield);
const int ret = user->load_user(dpp, null_yield);
if (ret < 0) {
/* We aren't trying to recover from ENOENT here. It's supposed that creating
* someone else's account isn't a thing we want to support in this filter. */
@ -263,7 +263,7 @@ void SysReqApplier<T>::load_acct_info(const DoutPrefixProvider* dpp, RGWUserInfo
* reasons. rgw_get_user_info_by_uid doesn't trigger the operator=() but
* calls ::decode instead. */
std::unique_ptr<rgw::sal::User> user = store->get_user(effective_uid);
if (user->load_by_id(dpp, null_yield) < 0) {
if (user->load_user(dpp, null_yield) < 0) {
//ldpp_dout(dpp, 0) << "User lookup failed!" << dendl;
throw -EACCES;
}

View File

@ -487,7 +487,7 @@ int RGWBucket::init(rgw::sal::Store* _store, RGWBucketAdminOpState& op_state,
op_state.set_bucket(bucket->clone());
if (!rgw::sal::User::empty(user.get())) {
r = user->load_by_id(dpp, y);
r = user->load_user(dpp, y);
if (r < 0) {
set_err_msg(err_msg, "failed to fetch user info");
return r;

View File

@ -1004,9 +1004,8 @@ namespace rgw {
}
if (token.valid() && (ldh->auth(token.id, token.key) == 0)) {
/* try to store user if it doesn't already exist */
if (user->load_by_id(dpp, null_yield) < 0) {
int ret = user->store_info(dpp, null_yield, RGWUserCtl::PutParams()
.set_exclusive(true));
if (user->load_user(dpp, null_yield) < 0) {
int ret = user->store_user(dpp, null_yield, true);
if (ret < 0) {
lsubdout(get_context(), rgw, 10)
<< "NOTICE: failed to store new user's info: ret=" << ret

View File

@ -249,7 +249,7 @@ public:
rgw_user uid(uid_str);
std::unique_ptr<rgw::sal::User> user = env.store->get_user(uid);
int ret = user->load_by_id(this, null_yield);
int ret = user->load_user(this, null_yield);
if (ret < 0) {
derr << "ERROR: failed reading user info: uid=" << uid << " ret="
<< ret << dendl;

View File

@ -227,7 +227,7 @@ int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider *dpp,
ldpp_dout(dpp, 0) << "WARNING: couldn't find acl header for bucket, generating default" << dendl;
std::unique_ptr<rgw::sal::User> user = store->get_user(bucket_info.owner);
/* object exists, but policy is broken */
int r = user->load_by_id(dpp, y);
int r = user->load_user(dpp, y);
if (r < 0)
return r;
@ -261,7 +261,7 @@ static int get_obj_policy_from_attr(const DoutPrefixProvider *dpp,
/* object exists, but policy is broken */
ldpp_dout(dpp, 0) << "WARNING: couldn't find acl header for object, generating default" << dendl;
std::unique_ptr<rgw::sal::User> user = store->get_user(bucket_info.owner);
ret = user->load_by_id(dpp, y);
ret = user->load_user(dpp, y);
if (ret < 0)
return ret;
@ -640,12 +640,11 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::Store* st
/* handle user ACL only for those APIs which support it */
if (s->user_acl) {
rgw::sal::Attrs uattrs;
std::unique_ptr<rgw::sal::User> acl_user = store->get_user(acct_acl_user.uid);
ret = acl_user->read_attrs(dpp, y, &uattrs);
ret = acl_user->read_attrs(dpp, y);
if (!ret) {
ret = get_user_policy_from_attr(s->cct, uattrs, *s->user_acl);
ret = get_user_policy_from_attr(s->cct, acl_user->get_attrs(), *s->user_acl);
}
if (-ENOENT == ret) {
/* In already existing clusters users won't have ACL. In such case
@ -668,10 +667,11 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::Store* st
// hence the check for user type
if (! s->user->get_id().empty() && s->auth.identity->get_identity_type() != TYPE_ROLE) {
try {
rgw::sal::Attrs uattrs;
ret = s->user->read_attrs(dpp, y, &uattrs);
ret = s->user->read_attrs(dpp, y);
if (ret == 0) {
auto user_policies = get_iam_user_policy_from_attr(s->cct, uattrs, s->user->get_tenant());
auto user_policies = get_iam_user_policy_from_attr(s->cct,
s->user->get_attrs(),
s->user->get_tenant());
s->iam_user_policies.insert(s->iam_user_policies.end(),
std::make_move_iterator(user_policies.begin()),
std::make_move_iterator(user_policies.end()));
@ -1298,7 +1298,7 @@ int RGWOp::init_quota()
if (s->user->get_id() == s->bucket_owner.get_id()) {
user = s->user.get();
} else {
int r = owner_user->load_by_id(this, s->yield);
int r = owner_user->load_user(this, s->yield);
if (r < 0)
return r;
user = owner_user.get();
@ -2288,7 +2288,7 @@ void RGWListBuckets::execute(optional_yield y)
}
if (supports_account_metadata()) {
op_ret = s->user->read_attrs(this, s->yield, &attrs);
op_ret = s->user->read_attrs(this, s->yield);
if (op_ret < 0) {
goto send_end;
}
@ -4347,10 +4347,11 @@ int RGWPutMetadataAccount::init_processing(optional_yield y)
return op_ret;
}
op_ret = s->user->read_attrs(this, y, &orig_attrs, &acct_op_tracker);
op_ret = s->user->read_attrs(this, y);
if (op_ret < 0) {
return op_ret;
}
orig_attrs = s->user->get_attrs();
if (has_policy) {
bufferlist acl_bl;
@ -4407,11 +4408,10 @@ int RGWPutMetadataAccount::verify_permission(optional_yield y)
void RGWPutMetadataAccount::execute(optional_yield y)
{
/* Params have been extracted earlier. See init_processing(). */
op_ret = s->user->load_by_id(this, y);
op_ret = s->user->load_user(this, y);
if (op_ret < 0) {
return;
}
acct_op_tracker = s->user->get_version_tracker();
/* Handle the TempURL-related stuff. */
if (!temp_url_keys.empty()) {
@ -4427,10 +4427,8 @@ void RGWPutMetadataAccount::execute(optional_yield y)
/* We are passing here the current (old) user info to allow the function
* optimize-out some operations. */
op_ret = s->user->store_info(this, y, RGWUserCtl::PutParams()
.set_old_info(&s->user->get_info())
.set_objv_tracker(&acct_op_tracker)
.set_attrs(&attrs));
s->user->set_attrs(attrs);
op_ret = s->user->store_user(this, y, false, &s->user->get_info());
}
int RGWPutMetadataBucket::verify_permission(optional_yield y)

View File

@ -802,7 +802,6 @@ protected:
std::string end_marker;
int64_t limit;
uint64_t limit_max;
rgw::sal::Attrs attrs;
bool is_truncated;
RGWUsageStats global_stats;
@ -1348,8 +1347,6 @@ protected:
RGWQuotaInfo new_quota;
bool new_quota_extracted;
RGWObjVersionTracker acct_op_tracker;
RGWAccessControlPolicy policy;
bool has_policy;

View File

@ -1849,9 +1849,8 @@ int RGWHandler_REST::init_permissions(RGWOp* op, optional_yield y)
// We don't need user policies in case of STS token returned by AssumeRole, hence the check for user type
if (! s->user->get_id().empty() && s->auth.identity->get_identity_type() != TYPE_ROLE) {
try {
rgw::sal::Attrs uattrs;
if (auto ret = s->user->read_attrs(s, y, &uattrs); ! ret) {
auto user_policies = get_iam_user_policy_from_attr(s->cct, uattrs, s->user->get_tenant());
if (auto ret = s->user->read_attrs(s, y); ! ret) {
auto user_policies = get_iam_user_policy_from_attr(s->cct, s->user->get_attrs(), s->user->get_tenant());
s->iam_user_policies.insert(s->iam_user_policies.end(),
std::make_move_iterator(user_policies.begin()),
std::make_move_iterator(user_policies.end()));

View File

@ -6042,7 +6042,7 @@ rgw::auth::s3::STSEngine::authenticate(
user = store->get_user(token.user);
if (! token.user.empty() && token.acct_type != TYPE_ROLE) {
// get user info
int ret = user->load_by_id(dpp, y);
int ret = user->load_user(dpp, y);
if (ret < 0) {
ldpp_dout(dpp, 5) << "ERROR: failed reading user info: uid=" << token.user << dendl;
return result_t::reject(-EPERM);

View File

@ -175,7 +175,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets)
dump_account_metadata(s,
global_stats,
policies_stats,
attrs,
s->user->get_attrs(),
s->user->get_info().user_quota,
static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
dump_errno(s);
@ -281,7 +281,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_end()
dump_account_metadata(s,
global_stats,
policies_stats,
attrs,
s->user->get_attrs(),
s->user->get_info().user_quota,
static_cast<RGWAccessControlPolicy_SWIFTAcct&>(*s->user_acl));
dump_errno(s);
@ -545,7 +545,8 @@ static void dump_container_metadata(struct req_state *s,
void RGWStatAccount_ObjStore_SWIFT::execute(optional_yield y)
{
RGWStatAccount_ObjStore::execute(y);
op_ret = s->user->read_attrs(s, s->yield, &attrs);
op_ret = s->user->read_attrs(s, s->yield);
attrs = s->user->get_attrs();
}
void RGWStatAccount_ObjStore_SWIFT::send_response()
@ -2082,7 +2083,7 @@ void RGWFormPost::get_owner_info(const req_state* const s,
const rgw_user tenanted_uid(uid.id, uid.id);
user = store->get_user(tenanted_uid);
if (user->load_by_id(s, s->yield) >= 0) {
if (user->load_user(s, s->yield) >= 0) {
/* Succeeded. */
found = true;
}
@ -2090,7 +2091,7 @@ void RGWFormPost::get_owner_info(const req_state* const s,
if (!found) {
user = store->get_user(uid);
if (user->load_by_id(s, s->yield) < 0) {
if (user->load_user(s, s->yield) < 0) {
throw -EPERM;
}
}
@ -2107,7 +2108,7 @@ void RGWFormPost::get_owner_info(const req_state* const s,
<< dendl;
user = store->get_user(bucket->get_info().owner);
if (user->load_by_id(s, s->yield) < 0) {
if (user->load_user(s, s->yield) < 0) {
throw -EPERM;
}

View File

@ -120,14 +120,13 @@ void RGWPutUserPolicy::execute(optional_yield y)
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(user_name));
op_ret = user->load_by_id(s, s->yield);
op_ret = user->load_user(s, s->yield);
if (op_ret < 0) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
rgw::sal::Attrs uattrs;
op_ret = user->read_attrs(s, s->yield, &uattrs);
op_ret = user->read_attrs(s, s->yield);
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
@ -143,20 +142,16 @@ void RGWPutUserPolicy::execute(optional_yield y)
try {
const Policy p(s->cct, s->user->get_tenant(), bl);
map<string, string> policies;
if (auto it = uattrs.find(RGW_ATTR_USER_POLICY); it != uattrs.end()) {
bufferlist out_bl = uattrs[RGW_ATTR_USER_POLICY];
if (auto it = user->get_attrs().find(RGW_ATTR_USER_POLICY); it != user->get_attrs().end()) {
bufferlist out_bl = it->second;
decode(policies, out_bl);
}
bufferlist in_bl;
policies[policy_name] = policy;
encode(policies, in_bl);
uattrs[RGW_ATTR_USER_POLICY] = in_bl;
user->get_attrs()[RGW_ATTR_USER_POLICY] = in_bl;
RGWObjVersionTracker objv_tracker;
op_ret = user->store_info(s, s->yield,
RGWUserCtl::PutParams()
.set_objv_tracker(&objv_tracker)
.set_attrs(&uattrs));
op_ret = user->store_user(s, s->yield, false);
if (op_ret < 0) {
op_ret = -ERR_INTERNAL_ERROR;
}
@ -201,8 +196,7 @@ void RGWGetUserPolicy::execute(optional_yield y)
}
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(user_name));
rgw::sal::Attrs uattrs;
op_ret = user->read_attrs(s, s->yield, &uattrs);
op_ret = user->read_attrs(s, s->yield);
if (op_ret == -ENOENT) {
ldpp_dout(this, 0) << "ERROR: attrs not found for user" << user_name << dendl;
op_ret = -ERR_NO_SUCH_ENTITY;
@ -216,8 +210,8 @@ void RGWGetUserPolicy::execute(optional_yield y)
s->formatter->close_section();
s->formatter->open_object_section("GetUserPolicyResult");
map<string, string> policies;
if (auto it = uattrs.find(RGW_ATTR_USER_POLICY); it != uattrs.end()) {
bufferlist bl = uattrs[RGW_ATTR_USER_POLICY];
if (auto it = user->get_attrs().find(RGW_ATTR_USER_POLICY); it != user->get_attrs().end()) {
bufferlist bl = it->second;
decode(policies, bl);
if (auto it = policies.find(policy_name); it != policies.end()) {
policy = policies[policy_name];
@ -265,8 +259,7 @@ void RGWListUserPolicies::execute(optional_yield y)
}
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(user_name));
rgw::sal::Attrs uattrs;
op_ret = user->read_attrs(s, s->yield, &uattrs);
op_ret = user->read_attrs(s, s->yield);
if (op_ret == -ENOENT) {
ldpp_dout(this, 0) << "ERROR: attrs not found for user" << user_name << dendl;
op_ret = -ERR_NO_SUCH_ENTITY;
@ -275,13 +268,13 @@ void RGWListUserPolicies::execute(optional_yield y)
if (op_ret == 0) {
map<string, string> policies;
if (auto it = uattrs.find(RGW_ATTR_USER_POLICY); it != uattrs.end()) {
if (auto it = user->get_attrs().find(RGW_ATTR_USER_POLICY); it != user->get_attrs().end()) {
s->formatter->open_object_section("ListUserPoliciesResponse");
s->formatter->open_object_section("ResponseMetadata");
s->formatter->dump_string("RequestId", s->trans_id);
s->formatter->close_section();
s->formatter->open_object_section("ListUserPoliciesResult");
bufferlist bl = uattrs[RGW_ATTR_USER_POLICY];
bufferlist bl = it->second;
decode(policies, bl);
for (const auto& p : policies) {
s->formatter->open_object_section("PolicyNames");
@ -327,14 +320,13 @@ void RGWDeleteUserPolicy::execute(optional_yield y)
}
std::unique_ptr<rgw::sal::User> user = store->get_user(rgw_user(user_name));
op_ret = user->load_by_id(s, s->yield);
op_ret = user->load_user(s, s->yield);
if (op_ret < 0) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
}
rgw::sal::Attrs uattrs;
op_ret = user->read_attrs(this, s->yield, &uattrs);
op_ret = user->read_attrs(this, s->yield);
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_SUCH_ENTITY;
return;
@ -353,22 +345,17 @@ void RGWDeleteUserPolicy::execute(optional_yield y)
}
map<string, string> policies;
if (auto it = uattrs.find(RGW_ATTR_USER_POLICY); it != uattrs.end()) {
bufferlist out_bl = uattrs[RGW_ATTR_USER_POLICY];
if (auto it = user->get_attrs().find(RGW_ATTR_USER_POLICY); it != user->get_attrs().end()) {
bufferlist out_bl = it->second;
decode(policies, out_bl);
if (auto p = policies.find(policy_name); p != policies.end()) {
bufferlist in_bl;
policies.erase(p);
encode(policies, in_bl);
uattrs[RGW_ATTR_USER_POLICY] = in_bl;
user->get_attrs()[RGW_ATTR_USER_POLICY] = in_bl;
RGWObjVersionTracker objv_tracker;
op_ret = user->store_info(s, s->yield,
RGWUserCtl::PutParams()
.set_old_info(&user->get_info())
.set_objv_tracker(&objv_tracker)
.set_attrs(&uattrs));
op_ret = user->store_user(s, s->yield, false);
if (op_ret < 0) {
op_ret = -ERR_INTERNAL_ERROR;
}

View File

@ -242,6 +242,7 @@ class User {
protected:
RGWUserInfo info;
RGWObjVersionTracker objv_tracker;
Attrs attrs;
public:
User() : info() {}
@ -270,7 +271,7 @@ class User {
const RGWUserCaps& get_caps() const { return info.caps; }
static bool empty(User* u) { return (!u || u->info.user_id.id.empty()); }
static bool empty(std::unique_ptr<User>& u) { return (!u || u->info.user_id.id.empty()); }
virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y, Attrs* uattrs, RGWObjVersionTracker* tracker = nullptr) = 0;
virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
virtual int read_stats(optional_yield y, RGWStorageStats* stats,
ceph::real_time* last_stats_sync = nullptr,
ceph::real_time* last_stats_update = nullptr) = 0;
@ -281,11 +282,12 @@ class User {
map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) = 0;
virtual RGWObjVersionTracker& get_version_tracker() { return objv_tracker; }
virtual Attrs& get_attrs() { return attrs; }
virtual void set_attrs(Attrs& _attrs) { attrs = _attrs; }
/* Placeholders */
virtual int load_by_id(const DoutPrefixProvider* dpp, optional_yield y) = 0;
virtual int store_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) = 0;
virtual int remove_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::RemoveParams& params = {}) = 0;
virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) = 0;
virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
/* dang temporary; will be removed when User is complete */
RGWUserInfo& get_info() { return info; }

View File

@ -82,7 +82,7 @@ static int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider* dpp,
} else {
ldout(store->ctx(), 0) << "WARNING: couldn't find acl header for bucket, generating default" << dendl;
/* object exists, but policy is broken */
int r = user.load_by_id(dpp, y);
int r = user.load_user(dpp, y);
if (r < 0)
return r;
@ -148,9 +148,9 @@ Bucket* RadosUser::create_bucket(rgw_bucket& bucket,
return NULL;
}
int RadosUser::read_attrs(const DoutPrefixProvider* dpp, optional_yield y, Attrs* uattrs, RGWObjVersionTracker* tracker)
int RadosUser::read_attrs(const DoutPrefixProvider* dpp, optional_yield y)
{
return store->ctl()->user->get_attrs_by_uid(dpp, get_id(), uattrs, y, tracker);
return store->ctl()->user->get_attrs_by_uid(dpp, get_id(), &attrs, y, &objv_tracker);
}
int RadosUser::read_stats(optional_yield y, RGWStorageStats* stats,
@ -188,19 +188,24 @@ int RadosUser::trim_usage(uint64_t start_epoch, uint64_t end_epoch)
return store->getRados()->trim_usage(get_id(), bucket_name, start_epoch, end_epoch);
}
int RadosUser::load_by_id(const DoutPrefixProvider* dpp, optional_yield y)
int RadosUser::load_user(const DoutPrefixProvider* dpp, optional_yield y)
{
return store->ctl()->user->get_info_by_uid(dpp, info.user_id, &info, y, RGWUserCtl::GetParams().set_objv_tracker(&objv_tracker));
}
int RadosUser::store_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::PutParams& params)
int RadosUser::store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info)
{
return store->ctl()->user->store_info(dpp, info, y, params);
return store->ctl()->user->store_info(dpp, info, y,
RGWUserCtl::PutParams().set_objv_tracker(&objv_tracker)
.set_exclusive(exclusive)
.set_attrs(&attrs)
.set_old_info(old_info));
}
int RadosUser::remove_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::RemoveParams& params)
int RadosUser::remove_user(const DoutPrefixProvider* dpp, optional_yield y)
{
return store->ctl()->user->remove_info(dpp, info, y, params);
return store->ctl()->user->remove_info(dpp, info, y,
RGWUserCtl::RemoveParams().set_objv_tracker(&objv_tracker));
}
/* Placeholder */

View File

@ -52,7 +52,7 @@ class RadosUser : public User {
uint64_t max, bool need_stats, BucketList& buckets,
optional_yield y) override;
virtual Bucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time) override;
virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y, Attrs* uattrs, RGWObjVersionTracker* tracker) override;
virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) override;
virtual int read_stats(optional_yield y, RGWStorageStats* stats,
ceph::real_time* last_stats_sync = nullptr,
ceph::real_time* last_stats_update = nullptr) override;
@ -63,10 +63,9 @@ class RadosUser : public User {
map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
virtual int trim_usage(uint64_t start_epoch, uint64_t end_epoch) override;
/* Placeholders */
virtual int load_by_id(const DoutPrefixProvider* dpp, optional_yield y) override;
virtual int store_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::PutParams& params = {}) override;
virtual int remove_info(const DoutPrefixProvider* dpp, optional_yield y, const RGWUserCtl::RemoveParams& params = {}) override;
virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) override;
virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) override;
virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) override;
friend class RadosBucket;
};

View File

@ -316,15 +316,13 @@ int STSService::storeARN(const DoutPrefixProvider *dpp, string& arn, optional_yi
{
int ret = 0;
std::unique_ptr<rgw::sal::User> user = store->get_user(user_id);
if ((ret = user->load_by_id(dpp, y)) < 0) {
if ((ret = user->load_user(dpp, y)) < 0) {
return -ERR_NO_SUCH_ENTITY;
}
user->get_info().assumed_role_arn = arn;
ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
.set_old_info(&user->get_info())
.set_exclusive(false));
ret = user->store_user(dpp, y, false, &user->get_info());
if (ret < 0) {
return -ERR_INTERNAL_ERROR;
}

View File

@ -92,7 +92,7 @@ void TempURLEngine::get_owner_info(const DoutPrefixProvider* dpp, const req_stat
if (uid.tenant.empty()) {
rgw_user tenanted_uid(uid.id, uid.id);
user = store->get_user(tenanted_uid);
if (user->load_by_id(dpp, s->yield) >= 0) {
if (user->load_user(dpp, s->yield) >= 0) {
/* Succeeded */
found = true;
}
@ -100,7 +100,7 @@ void TempURLEngine::get_owner_info(const DoutPrefixProvider* dpp, const req_stat
if (!found) {
user = store->get_user(uid);
if (user->load_by_id(dpp, s->yield) < 0) {
if (user->load_user(dpp, s->yield) < 0) {
throw -EPERM;
}
}
@ -122,7 +122,7 @@ void TempURLEngine::get_owner_info(const DoutPrefixProvider* dpp, const req_stat
std::unique_ptr<rgw::sal::User> user;
user = store->get_user(bucket->get_info().owner);
if (user->load_by_id(dpp, s->yield) < 0) {
if (user->load_user(dpp, s->yield) < 0) {
throw -EPERM;
}

View File

@ -1491,7 +1491,7 @@ int RGWUser::init(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state,
if (!user_id.empty() && (user_id.compare(RGW_USER_ANON_ID) != 0)) {
user = store->get_user(user_id);
found = (user->load_by_id(dpp, y) >= 0);
found = (user->load_user(dpp, y) >= 0);
op_state.found_by_uid = found;
}
if (store->ctx()->_conf.get_val<bool>("rgw_user_unique_email")) {
@ -1565,9 +1565,8 @@ int RGWUser::update(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state
RGWUserInfo *pold_info = (is_populated() ? &old_info : nullptr);
ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
.set_old_info(pold_info)
.set_objv_tracker(&op_state.objv));
ret = user->store_user(dpp, y, false, pold_info);
op_state.objv = user->get_version_tracker();
if (ret < 0) {
set_err_msg(err_msg, "unable to store user info");
return ret;
@ -1663,12 +1662,9 @@ int RGWUser::execute_rename(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
std::unique_ptr<rgw::sal::User> user;
user = store->get_user(new_user->get_id());
RGWObjVersionTracker objv;
const bool exclusive = !op_state.get_overwrite_new_user(); // overwrite if requested
ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
.set_objv_tracker(&objv)
.set_exclusive(exclusive));
ret = user->store_user(dpp, y, exclusive);
if (ret == -EEXIST) {
set_err_msg(err_msg, "user name given by --new-uid already exists");
return ret;
@ -1731,7 +1727,7 @@ int RGWUser::execute_rename(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
// associated index objects
RGWUserInfo& user_info = op_state.get_user_info();
user_info.user_id = new_user->get_id();
op_state.objv = objv;
op_state.objv = user->get_version_tracker();
rename_swift_keys(new_user->get_id(), user_info.swift_keys);
@ -1951,7 +1947,7 @@ int RGWUser::execute_remove(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
} while (buckets.is_truncated());
ret = user->remove_info(dpp, y, RGWUserCtl::RemoveParams().set_objv_tracker(&op_state.objv));
ret = user->remove_user(dpp, y);
if (ret < 0) {
set_err_msg(err_msg, "unable to remove user from RADOS");
return ret;

View File

@ -34,7 +34,7 @@ public:
return nullptr;
}
virtual int read_attrs(const DoutPrefixProvider *dpp, optional_yield y, sal::Attrs* uattrs, RGWObjVersionTracker* tracker) override {
virtual int read_attrs(const DoutPrefixProvider *dpp, optional_yield y) override {
return 0;
}
@ -58,15 +58,15 @@ public:
return 0;
}
virtual int load_by_id(const DoutPrefixProvider *dpp, optional_yield y) override {
virtual int load_user(const DoutPrefixProvider *dpp, optional_yield y) override {
return 0;
}
virtual int store_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::PutParams& params) override {
virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info) override {
return 0;
}
virtual int remove_info(const DoutPrefixProvider *dpp, optional_yield y, const RGWUserCtl::RemoveParams& params) override {
virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) override {
return 0;
}