Skip to content

Commit

Permalink
rgw: No null_yield in rgw_role
Browse files Browse the repository at this point in the history
Signed-off-by: Adam C. Emerson <[email protected]>
  • Loading branch information
adamemerson committed Nov 13, 2020
1 parent 89cb013 commit 1fcc217
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 72 deletions.
14 changes: 7 additions & 7 deletions src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5783,7 +5783,7 @@ int main(int argc, const char **argv)
return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
ret = role.get();
ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand Down Expand Up @@ -5811,7 +5811,7 @@ int main(int argc, const char **argv)
}

RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
ret = role.get();
ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand All @@ -5826,7 +5826,7 @@ int main(int argc, const char **argv)
case OPT::ROLE_LIST:
{
vector<RGWRole> result;
ret = RGWRole::get_roles_by_path_prefix(store->getRados(), g_ceph_context, path_prefix, tenant, result);
ret = RGWRole::get_roles_by_path_prefix(store->getRados(), g_ceph_context, path_prefix, tenant, result, null_yield);
if (ret < 0) {
return -ret;
}
Expand Down Expand Up @@ -5859,7 +5859,7 @@ int main(int argc, const char **argv)
}

RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
ret = role.get();
ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand All @@ -5878,7 +5878,7 @@ int main(int argc, const char **argv)
return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
ret = role.get();
ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand All @@ -5898,7 +5898,7 @@ int main(int argc, const char **argv)
return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
int ret = role.get();
int ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand All @@ -5922,7 +5922,7 @@ int main(int argc, const char **argv)
return -EINVAL;
}
RGWRole role(g_ceph_context, store->getRados()->pctl, role_name, tenant);
ret = role.get();
ret = role.get(null_yield);
if (ret < 0) {
return -ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ int RGWBucketAdminOp::remove_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdm
std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(op_state.get_user_id());

int ret = store->get_bucket(user.get(), user->get_tenant(), op_state.get_bucket_name(),
&bucket);
&bucket, y);
if (ret < 0)
return ret;

Expand Down
16 changes: 8 additions & 8 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ int rgw_build_bucket_policies(rgw::sal::RGWRadosStore* store, struct req_state*
/* check if copy source is within the current domain */
if (!s->src_bucket_name.empty()) {
std::unique_ptr<rgw::sal::RGWBucket> src_bucket;
ret = store->get_bucket(nullptr, s->src_tenant_name, s->src_bucket_name, &src_bucket);
ret = store->get_bucket(nullptr, s->src_tenant_name, s->src_bucket_name, &src_bucket, y);
if (ret == 0) {
ret = src_bucket->load_by_name(s->src_tenant_name, s->src_bucket_name,
s->bucket_instance_id, &obj_ctx, s->yield);
Expand All @@ -562,7 +562,7 @@ int rgw_build_bucket_policies(rgw::sal::RGWRadosStore* store, struct req_state*
if (!s->bucket_name.empty()) {
s->bucket_exists = true;

ret = store->get_bucket(s->user.get(), rgw_bucket(rgw_bucket_key(s->bucket_tenant, s->bucket_name, s->bucket_instance_id)), &s->bucket);
ret = store->get_bucket(s->user.get(), rgw_bucket(rgw_bucket_key(s->bucket_tenant, s->bucket_name, s->bucket_instance_id)), &s->bucket, y);
if (ret < 0) {
if (ret != -ENOENT) {
string bucket_log;
Expand Down Expand Up @@ -1813,7 +1813,7 @@ int RGWGetObj::handle_user_manifest(const char *prefix, optional_yield y)

if (bucket_name.compare(s->bucket->get_name()) != 0) {
map<string, bufferlist> bucket_attrs;
r = store->get_bucket(s->user.get(), s->user->get_tenant(), bucket_name, &ubucket);
r = store->get_bucket(s->user.get(), s->user->get_tenant(), bucket_name, &ubucket, y);
if (r < 0) {
ldpp_dout(this, 0) << "could not get bucket info for bucket="
<< bucket_name << dendl;
Expand Down Expand Up @@ -1942,7 +1942,7 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl, optional_yield y)

std::unique_ptr<rgw::sal::RGWBucket> tmp_bucket;
auto obj_ctx = store->svc()->sysobj->init_obj_ctx();
int r = store->get_bucket(s->user.get(), s->user->get_tenant(), bucket_name, &tmp_bucket);
int r = store->get_bucket(s->user.get(), s->user->get_tenant(), bucket_name, &tmp_bucket, y);
if (r < 0) {
ldpp_dout(this, 0) << "could not get bucket info for bucket="
<< bucket_name << dendl;
Expand Down Expand Up @@ -2742,7 +2742,7 @@ void RGWStatBucket::execute(optional_yield y)
return;
}

op_ret = store->get_bucket(s->user.get(), s->bucket->get_key(), &bucket);
op_ret = store->get_bucket(s->user.get(), s->bucket->get_key(), &bucket, y);
if (op_ret) {
return;
}
Expand Down Expand Up @@ -3103,7 +3103,7 @@ void RGWCreateBucket::execute(optional_yield y)

/* we need to make sure we read bucket info, it's not read before for this
* specific request */
op_ret = store->get_bucket(s->user.get(), s->bucket_tenant, s->bucket_name, &s->bucket);
op_ret = store->get_bucket(s->user.get(), s->bucket_tenant, s->bucket_name, &s->bucket, y);
if (op_ret < 0 && op_ret != -ENOENT)
return;
s->bucket_exists = (op_ret != -ENOENT);
Expand Down Expand Up @@ -6627,7 +6627,7 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path, optional_yie
ACLOwner bowner;
RGWObjVersionTracker ot;

int ret = store->get_bucket(s->user.get(), s->user->get_tenant(), path.bucket_name, &bucket);
int ret = store->get_bucket(s->user.get(), s->user->get_tenant(), path.bucket_name, &bucket, y);
if (ret < 0) {
goto binfo_fail;
}
Expand Down Expand Up @@ -7018,7 +7018,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path,
std::unique_ptr<rgw::sal::RGWBucket> bucket;
ACLOwner bowner;

op_ret = store->get_bucket(s->user.get(), rgw_bucket(rgw_bucket_key(s->user->get_tenant(), bucket_name)), &bucket);
op_ret = store->get_bucket(s->user.get(), rgw_bucket(rgw_bucket_key(s->user->get_tenant(), bucket_name)), &bucket, y);
if (op_ret == -ENOENT) {
ldpp_dout(this, 20) << "non existent directory=" << bucket_name << dendl;
} else if (op_ret < 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class RGWHandler {
return 0;
}

virtual int retarget(RGWOp* op, RGWOp** new_op) {
virtual int retarget(RGWOp* op, RGWOp** new_op, optional_yield) {
*new_op = op;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int rgw_process_authenticated(RGWHandler_REST * const handler,
*/
if (! skip_retarget) {
ldpp_dout(op, 2) << "recalculating target" << dendl;
ret = handler->retarget(op, &op);
ret = handler->retarget(op, &op, y);
if (ret < 0) {
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rest_bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void RGWOp_Bucket_Remove::execute(optional_yield y)
RESTArgs::get_string(s, "bucket", bucket_name, &bucket_name);
RESTArgs::get_bool(s, "purge-objects", false, &delete_children);

op_ret = store->get_bucket(nullptr, string(), bucket_name, &bucket);
op_ret = store->get_bucket(nullptr, string(), bucket_name, &bucket, y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "get_bucket returned ret=" << op_ret << dendl;
return;
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_rest_role.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int RGWRestRole::verify_permission(optional_yield y)

string role_name = s->info.args.get("RoleName");
RGWRole role(s->cct, store->getRados()->pctl, role_name, s->user->get_tenant());
if (op_ret = role.get(); op_ret < 0) {
if (op_ret = role.get(y); op_ret < 0) {
if (op_ret == -ENOENT) {
op_ret = -ERR_NO_ROLE_FOUND;
}
Expand Down Expand Up @@ -230,7 +230,7 @@ void RGWGetRole::execute(optional_yield y)
return;
}
RGWRole role(s->cct, store->getRados()->pctl, role_name, s->user->get_tenant());
op_ret = role.get();
op_ret = role.get(y);

if (op_ret == -ENOENT) {
op_ret = -ERR_NO_ROLE_FOUND;
Expand Down Expand Up @@ -322,7 +322,7 @@ void RGWListRoles::execute(optional_yield y)
return;
}
vector<RGWRole> result;
op_ret = RGWRole::get_roles_by_path_prefix(store->getRados(), s->cct, path_prefix, s->user->get_tenant(), result);
op_ret = RGWRole::get_roles_by_path_prefix(store->getRados(), s->cct, path_prefix, s->user->get_tenant(), result, y);

if (op_ret == 0) {
s->formatter->open_array_section("ListRolesResponse");
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4910,14 +4910,14 @@ int RGWHandler_REST_S3Website::init(rgw::sal::RGWRadosStore *store, req_state *s
return RGWHandler_REST_S3::init(store, s, cio);
}

int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {
int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op, optional_yield y) {
*new_op = op;
ldpp_dout(s, 10) << __func__ << " Starting retarget" << dendl;

if (!(s->prot_flags & RGW_REST_WEBSITE))
return 0;

int ret = store->get_bucket(nullptr, s->bucket_tenant, s->bucket_name, &s->bucket);
int ret = store->get_bucket(nullptr, s->bucket_tenant, s->bucket_name, &s->bucket, y);
if (ret < 0) {
// TODO-FUTURE: if the bucket does not exist, maybe expose it here?
return -ERR_NO_SUCH_BUCKET;
Expand Down Expand Up @@ -5877,7 +5877,7 @@ rgw::auth::s3::STSEngine::authenticate(
rgw::auth::RoleApplier::Role r;
if (! token.roleId.empty()) {
RGWRole role(s->cct, ctl, token.roleId);
if (role.get_by_id() < 0) {
if (role.get_by_id(y) < 0) {
return result_t::deny(-EPERM);
}
r.id = token.roleId;
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rest_s3website.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RGWHandler_REST_S3Website : public RGWHandler_REST_S3 {
std::string original_object_name; // object name before retarget()
bool web_dir() const;
protected:
int retarget(RGWOp *op, RGWOp **new_op) override;
int retarget(RGWOp *op, RGWOp **new_op, optional_yield y) override;
// TODO: this should be virtual I think, and ensure that it's always
// overridden, but that conflates that op_get/op_head are defined in this
// class and call this; and don't need to be overridden later.
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_rest_sts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ int RGWREST_STS::verify_permission(optional_yield y)
sts = std::move(_sts);

string rArn = s->info.args.get("RoleArn");
const auto& [ret, role] = sts.getRoleInfo(rArn);
const auto& [ret, role] = sts.getRoleInfo(rArn, y);
if (ret < 0) {
ldout(s->cct, 0) << "failed to get role info using role arn: " << rArn << dendl;
return ret;
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_rest_swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class RGWHandler_REST_Bucket_SWIFT : public RGWHandler_REST_SWIFT {
return website_handler->error_handler(err_no, error_content, y);
}

int retarget(RGWOp* op, RGWOp** new_op) override {
int retarget(RGWOp* op, RGWOp** new_op, optional_yield) override {
return website_handler->retarget_bucket(op, new_op);
}

Expand Down Expand Up @@ -478,7 +478,7 @@ class RGWHandler_REST_Obj_SWIFT : public RGWHandler_REST_SWIFT {
return website_handler->error_handler(err_no, error_content, y);
}

int retarget(RGWOp* op, RGWOp** new_op) override {
int retarget(RGWOp* op, RGWOp** new_op, optional_yield) override {
return website_handler->retarget_object(op, new_op);
}

Expand Down
33 changes: 17 additions & 16 deletions src/rgw/rgw_role.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int RGWRole::create(bool exclusive, optional_yield y)
}

/* check to see the name is not used */
ret = read_id(name, tenant, id);
ret = read_id(name, tenant, id, y);
if (exclusive && ret == 0) {
ldout(cct, 0) << "ERROR: name " << name << " already in use for role id "
<< id << dendl;
Expand Down Expand Up @@ -171,12 +171,12 @@ int RGWRole::delete_obj(optional_yield y)
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;

int ret = read_name();
int ret = read_name(y);
if (ret < 0) {
return ret;
}

ret = read_info();
ret = read_info(y);
if (ret < 0) {
return ret;
}
Expand Down Expand Up @@ -211,24 +211,24 @@ int RGWRole::delete_obj(optional_yield y)
return ret;
}

int RGWRole::get()
int RGWRole::get(optional_yield y)
{
int ret = read_name();
int ret = read_name(y);
if (ret < 0) {
return ret;
}

ret = read_info();
ret = read_info(y);
if (ret < 0) {
return ret;
}

return 0;
}

int RGWRole::get_by_id()
int RGWRole::get_by_id(optional_yield y)
{
int ret = read_info();
int ret = read_info(y);
if (ret < 0) {
return ret;
}
Expand Down Expand Up @@ -312,15 +312,15 @@ void RGWRole::decode_json(JSONObj *obj)
JSONDecoder::decode_json("assume_role_policy_document", trust_policy, obj);
}

int RGWRole::read_id(const string& role_name, const string& tenant, string& role_id)
int RGWRole::read_id(const string& role_name, const string& tenant, string& role_id, optional_yield y)
{
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;
string oid = tenant + get_names_oid_prefix() + role_name;
bufferlist bl;
auto obj_ctx = svc->sysobj->init_obj_ctx();

int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, null_yield);
int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, y);
if (ret < 0) {
return ret;
}
Expand All @@ -339,15 +339,15 @@ int RGWRole::read_id(const string& role_name, const string& tenant, string& role
return 0;
}

int RGWRole::read_info()
int RGWRole::read_info(optional_yield y)
{
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;
string oid = get_info_oid_prefix() + id;
bufferlist bl;
auto obj_ctx = svc->sysobj->init_obj_ctx();

int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, null_yield);
int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: failed reading role info from pool: " << pool.name <<
": " << id << ": " << cpp_strerror(-ret) << dendl;
Expand All @@ -367,15 +367,15 @@ int RGWRole::read_info()
return 0;
}

int RGWRole::read_name()
int RGWRole::read_name(optional_yield y)
{
auto svc = ctl->svc;
auto& pool = svc->zone->get_zone_params().roles_pool;
string oid = tenant + get_names_oid_prefix() + name;
bufferlist bl;
auto obj_ctx = svc->sysobj->init_obj_ctx();

int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, null_yield);
int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, NULL, NULL, y);
if (ret < 0) {
ldout(cct, 0) << "ERROR: failed reading role name from pool: " << pool.name << ": "
<< name << ": " << cpp_strerror(-ret) << dendl;
Expand Down Expand Up @@ -446,7 +446,8 @@ int RGWRole::get_roles_by_path_prefix(RGWRados *store,
CephContext *cct,
const string& path_prefix,
const string& tenant,
vector<RGWRole>& roles)
vector<RGWRole>& roles,
optional_yield y)
{
auto pool = store->svc.zone->get_zone_params().roles_pool;
string prefix;
Expand Down Expand Up @@ -492,7 +493,7 @@ int RGWRole::get_roles_by_path_prefix(RGWRados *store,

RGWRole role(cct, store->pctl);
role.set_id(id);
int ret = role.read_info();
int ret = role.read_info(y);
if (ret < 0) {
return ret;
}
Expand Down
Loading

0 comments on commit 1fcc217

Please sign in to comment.