From 4cd42ce3328b14e64d653d7072268abbad366003 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 10 Nov 2020 19:33:35 -0500 Subject: [PATCH] rgw/services: No null_yield Null yield is fine at top levels where we know what kind of thread we're running into, but do not belong in general use functions. Signed-off-by: Adam C. Emerson --- src/rgw/rgw_admin.cc | 45 ++++++------ src/rgw/rgw_bucket.cc | 46 +++++++------ src/rgw/rgw_bucket.h | 18 ++--- src/rgw/rgw_cr_tools.cc | 6 +- src/rgw/rgw_file.cc | 4 +- src/rgw/rgw_op.cc | 34 ++++----- src/rgw/rgw_quota.cc | 64 +++++++++-------- src/rgw/rgw_quota.h | 5 +- src/rgw/rgw_rados.cc | 15 ++-- src/rgw/rgw_rados.h | 28 ++++---- src/rgw/rgw_rest_bucket.cc | 2 +- src/rgw/rgw_rest_log.cc | 2 +- src/rgw/rgw_rest_user.cc | 8 +-- src/rgw/rgw_sal.h | 10 +-- src/rgw/rgw_sal_rados.cc | 27 ++++---- src/rgw/rgw_sal_rados.h | 10 +-- src/rgw/rgw_service.cc | 50 +++++++------- src/rgw/rgw_service.h | 18 ++--- src/rgw/rgw_user.cc | 88 +++++++++++++----------- src/rgw/rgw_user.h | 42 ++++++----- src/rgw/services/svc_bilog_rados.cc | 5 +- src/rgw/services/svc_bilog_rados.h | 3 +- src/rgw/services/svc_bucket_sobj.cc | 2 +- src/rgw/services/svc_bucket_sobj.h | 2 +- src/rgw/services/svc_bucket_sync_sobj.cc | 2 +- src/rgw/services/svc_bucket_sync_sobj.h | 2 +- src/rgw/services/svc_cls.cc | 4 +- src/rgw/services/svc_cls.h | 2 +- src/rgw/services/svc_config_key_rados.cc | 2 +- src/rgw/services/svc_config_key_rados.h | 2 +- src/rgw/services/svc_finisher.cc | 2 +- src/rgw/services/svc_finisher.h | 2 +- src/rgw/services/svc_mdlog.cc | 19 ++--- src/rgw/services/svc_mdlog.h | 8 +-- src/rgw/services/svc_notify.cc | 14 ++-- src/rgw/services/svc_notify.h | 4 +- src/rgw/services/svc_otp.cc | 2 +- src/rgw/services/svc_otp.h | 2 +- src/rgw/services/svc_rados.cc | 2 +- src/rgw/services/svc_rados.h | 2 +- src/rgw/services/svc_sync_modules.cc | 2 +- src/rgw/services/svc_sync_modules.h | 2 +- src/rgw/services/svc_sys_obj_cache.cc | 6 +- src/rgw/services/svc_sys_obj_cache.h | 2 +- src/rgw/services/svc_user.h | 18 +++-- src/rgw/services/svc_user_rados.cc | 77 +++++++++++---------- src/rgw/services/svc_user_rados.h | 39 ++++++----- src/rgw/services/svc_zone.cc | 77 +++++++++++---------- src/rgw/services/svc_zone.h | 29 ++++---- src/rgw/services/svc_zone_utils.cc | 2 +- src/rgw/services/svc_zone_utils.h | 2 +- src/test/rgw/test_rgw_lua.cc | 2 +- src/test/rgw/test_rgw_throttle.cc | 2 +- 53 files changed, 468 insertions(+), 397 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index c824e868434..8d2a1b3efa7 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1314,7 +1314,7 @@ int set_user_bucket_quota(OPT opt_cmd, RGWUser& user, RGWUserAdminOpState& op_st op_state.set_bucket_quota(user_info.bucket_quota); string err; - int r = user.modify(op_state, &err); + int r = user.modify(op_state, null_yield, &err); if (r < 0) { cerr << "ERROR: failed updating user info: " << cpp_strerror(-r) << ": " << err << std::endl; return -r; @@ -1332,7 +1332,7 @@ int set_user_quota(OPT opt_cmd, RGWUser& user, RGWUserAdminOpState& op_state, in op_state.set_user_quota(user_info.user_quota); string err; - int r = user.modify(op_state, &err); + int r = user.modify(op_state, null_yield, &err); if (r < 0) { cerr << "ERROR: failed updating user info: " << cpp_strerror(-r) << ": " << err << std::endl; return -r; @@ -5575,7 +5575,7 @@ int main(int argc, const char **argv) if (yes_i_really_mean_it) { user_op.set_overwrite_new_user(true); } - ret = user.rename(user_op, &err_msg); + ret = user.rename(user_op, null_yield, &err_msg); if (ret < 0) { if (ret == -EEXIST) { err_msg += ". to overwrite this user, add --yes-i-really-mean-it"; @@ -5588,7 +5588,7 @@ int main(int argc, const char **argv) case OPT::USER_ENABLE: case OPT::USER_SUSPEND: case OPT::USER_MODIFY: - ret = user.modify(user_op, &err_msg); + ret = user.modify(user_op, null_yield, &err_msg); if (ret < 0) { cerr << "could not modify user: " << err_msg << std::endl; return -ret; @@ -5604,7 +5604,7 @@ int main(int argc, const char **argv) break; case OPT::SUBUSER_MODIFY: - ret = user.subusers.modify(user_op, &err_msg); + ret = user.subusers.modify(user_op, null_yield, &err_msg); if (ret < 0) { cerr << "could not modify subuser: " << err_msg << std::endl; return -ret; @@ -5969,7 +5969,7 @@ int main(int argc, const char **argv) user_ids.push_back(user_id.id); ret = RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, f, - warnings_only); + null_yield, warnings_only); } else { /* list users in groups of max-keys, then perform user-bucket * limit-check on each group */ @@ -5991,7 +5991,7 @@ int main(int argc, const char **argv) /* ok, do the limit checks for this group */ ret = RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, f, - warnings_only); + null_yield, warnings_only); if (ret < 0) break; } @@ -6010,7 +6010,7 @@ int main(int argc, const char **argv) return -ENOENT; } } - RGWBucketAdminOp::info(store, bucket_op, f); + RGWBucketAdminOp::info(store, bucket_op, f, null_yield); } else { RGWBucketInfo bucket_info; int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket); @@ -6106,7 +6106,7 @@ int main(int argc, const char **argv) } bucket_op.set_fetch_stats(true); - int r = RGWBucketAdminOp::info(store, bucket_op, f); + int r = RGWBucketAdminOp::info(store, bucket_op, f, null_yield); if (r < 0) { cerr << "failure: " << cpp_strerror(-r) << ": " << err << std::endl; return -r; @@ -6286,7 +6286,7 @@ next: exit(1); } - int ret = store->svc()->zone->add_bucket_placement(pool); + int ret = store->svc()->zone->add_bucket_placement(pool, null_yield); if (ret < 0) cerr << "failed to add bucket placement: " << cpp_strerror(-ret) << std::endl; } @@ -6297,14 +6297,14 @@ next: exit(1); } - int ret = store->svc()->zone->remove_bucket_placement(pool); + int ret = store->svc()->zone->remove_bucket_placement(pool, null_yield); if (ret < 0) cerr << "failed to remove bucket placement: " << cpp_strerror(-ret) << std::endl; } if (opt_cmd == OPT::POOLS_LIST) { set pools; - int ret = store->svc()->zone->list_placement_set(pools); + int ret = store->svc()->zone->list_placement_set(pools, null_yield); if (ret < 0) { cerr << "could not list placement set: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -7408,7 +7408,7 @@ next: } if (opt_cmd == OPT::USER_CHECK) { - check_bad_user_bucket_mapping(store, user_id, fix); + check_bad_user_bucket_mapping(store, user_id, fix, null_yield); } if (opt_cmd == OPT::USER_STATS) { @@ -7428,7 +7428,7 @@ next: "so at most one of the two should be specified" << std::endl; return EINVAL; } - ret = store->ctl()->user->reset_stats(user_id); + ret = store->ctl()->user->reset_stats(user_id, null_yield); if (ret < 0) { cerr << "ERROR: could not reset user stats: " << cpp_strerror(-ret) << std::endl; @@ -7444,14 +7444,14 @@ next: cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; return -ret; } - ret = store->ctl()->bucket->sync_user_stats(user_id, bucket_info); + ret = store->ctl()->bucket->sync_user_stats(user_id, bucket_info, null_yield); if (ret < 0) { cerr << "ERROR: could not sync bucket stats: " << cpp_strerror(-ret) << std::endl; return -ret; } } else { - int ret = rgw_user_sync_all_stats(store, user_id); + int ret = rgw_user_sync_all_stats(store, user_id, null_yield); if (ret < 0) { cerr << "ERROR: could not sync user stats: " << cpp_strerror(-ret) << std::endl; @@ -7463,7 +7463,9 @@ next: RGWStorageStats stats; ceph::real_time last_stats_sync; ceph::real_time last_stats_update; - int ret = store->ctl()->user->read_stats(user_id, &stats, &last_stats_sync, &last_stats_update); + int ret = store->ctl()->user->read_stats(user_id, &stats, null_yield, + &last_stats_sync, + &last_stats_update); if (ret < 0) { if (ret == -ENOENT) { /* in case of ENOENT */ cerr << "User has not been initialized or user does not exist" << std::endl; @@ -7667,7 +7669,7 @@ next: if (opt_cmd == OPT::MDLOG_AUTOTRIM) { // need a full history for purging old mdlog periods - store->svc()->mdlog->init_oldest_log_period(); + store->svc()->mdlog->init_oldest_log_period(null_yield); RGWCoroutinesManager crs(store->ctx(), store->getRados()->get_cr_registry()); RGWHTTPManager http(store->ctx(), crs.get_completion_mgr()); @@ -8630,7 +8632,8 @@ next: return -ret; } map markers; - ret = store->svc()->bilog_rados->get_log_status(bucket_info, shard_id, &markers); + ret = store->svc()->bilog_rados->get_log_status(bucket_info, shard_id, + &markers, null_yield); if (ret < 0) { cerr << "ERROR: get_bi_log_status(): " << cpp_strerror(-ret) << std::endl; return -ret; @@ -8894,7 +8897,7 @@ next: user_info.mfa_ids.insert(totp_serial); user_op.set_mfa_ids(user_info.mfa_ids); string err; - ret = user.modify(user_op, &err); + ret = user.modify(user_op, null_yield, &err); if (ret < 0) { cerr << "ERROR: failed storing user info, error: " << err << std::endl; return -ret; @@ -8930,7 +8933,7 @@ next: user_info.mfa_ids.erase(totp_serial); user_op.set_mfa_ids(user_info.mfa_ids); string err; - ret = user.modify(user_op, &err); + ret = user.modify(user_op, null_yield, &err); if (ret < 0) { cerr << "ERROR: failed storing user info, error: " << err << std::endl; return -ret; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index b6006ae853a..34151df1fc7 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -157,10 +157,11 @@ int rgw_read_user_buckets(rgw::sal::RGWRadosStore * store, const string& marker, const string& end_marker, uint64_t max, - bool need_stats) + bool need_stats, + optional_yield y) { rgw::sal::RGWRadosUser user(store, user_id); - return user.list_buckets(marker, end_marker, max, need_stats, buckets); + return user.list_buckets(marker, end_marker, max, need_stats, buckets, y); } int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *bucket_name, string *bucket_id, int *shard_id) @@ -258,7 +259,8 @@ static void dump_mulipart_index_results(list& objs_to_unlink, } void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, - bool fix) + bool fix, + optional_yield y) { rgw::sal::RGWBucketList user_buckets; rgw::sal::RGWRadosUser user(store, user_id); @@ -269,7 +271,7 @@ void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_use size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk; do { - int ret = user.list_buckets(marker, string(), max_entries, false, user_buckets); + int ret = user.list_buckets(marker, string(), max_entries, false, user_buckets, y); if (ret < 0) { ldout(store->ctx(), 0) << "failed to read user buckets: " << cpp_strerror(-ret) << dendl; @@ -475,7 +477,7 @@ int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& buck return ret; } - ret = store->ctl()->bucket->sync_user_stats(info.owner, info); + ret = store->ctl()->bucket->sync_user_stats(info.owner, info, y); if (ret < 0) { dout(1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; } @@ -1372,7 +1374,7 @@ static int bucket_stats(rgw::sal::RGWRadosStore *store, int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const std::list& user_ids, - RGWFormatterFlusher& flusher, + RGWFormatterFlusher& flusher, optional_yield y, bool warnings_only) { int ret = 0; @@ -1403,7 +1405,7 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store, do { rgw::sal::RGWRadosUser user(store, rgw_user(user_id)); - ret = user.list_buckets(marker, string(), max_entries, false, buckets); + ret = user.list_buckets(marker, string(), max_entries, false, buckets, y); if (ret < 0) return ret; @@ -1488,7 +1490,8 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store, int RGWBucketAdminOp::info(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, - RGWFormatterFlusher& flusher) + RGWFormatterFlusher& flusher, + optional_yield y) { RGWBucket bucket; int ret = 0; @@ -1521,7 +1524,7 @@ int RGWBucketAdminOp::info(rgw::sal::RGWRadosStore *store, do { ret = user.list_buckets(marker, empty_end_marker, max_entries, - no_need_stats, buckets); + no_need_stats, buckets, y); if (ret < 0) { return ret; } @@ -2570,7 +2573,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_check() bci.info.bucket.tenant = tenant_name; // if the sync module never writes data, don't require the zone to specify all placement targets if (bihandler->svc.zone->sync_module_supports_writes()) { - ret = bihandler->svc.zone->select_bucket_location_by_rule(bci.info.placement_rule, &rule_info); + ret = bihandler->svc.zone->select_bucket_location_by_rule(bci.info.placement_rule, &rule_info, y); if (ret < 0) { ldout(cct, 0) << "ERROR: select_bucket_placement() returned " << ret << dendl; return ret; @@ -2969,8 +2972,8 @@ int RGWBucketCtl::link_bucket(const rgw_user& user_id, rgw_ep_info *pinfo) { return bm_handler->call([&](RGWSI_Bucket_EP_Ctx& ctx) { - return do_link_bucket(ctx, user_id, bucket, creation_time, y, - update_entrypoint, pinfo); + return do_link_bucket(ctx, user_id, bucket, creation_time, + update_entrypoint, pinfo, y); }); } @@ -2978,9 +2981,9 @@ int RGWBucketCtl::do_link_bucket(RGWSI_Bucket_EP_Ctx& ctx, const rgw_user& user_id, const rgw_bucket& bucket, ceph::real_time creation_time, - optional_yield y, bool update_entrypoint, - rgw_ep_info *pinfo) + rgw_ep_info *pinfo, + optional_yield y) { int ret; @@ -3009,7 +3012,7 @@ int RGWBucketCtl::do_link_bucket(RGWSI_Bucket_EP_Ctx& ctx, } } - ret = ctl.user->add_bucket(user_id, bucket, creation_time); + ret = ctl.user->add_bucket(user_id, bucket, creation_time, y); if (ret < 0) { ldout(cct, 0) << "ERROR: error adding bucket to user directory:" << " user=" << user_id @@ -3033,7 +3036,7 @@ int RGWBucketCtl::do_link_bucket(RGWSI_Bucket_EP_Ctx& ctx, return 0; done_err: - int r = do_unlink_bucket(ctx, user_id, bucket, y, true); + int r = do_unlink_bucket(ctx, user_id, bucket, true, y); if (r < 0) { ldout(cct, 0) << "ERROR: failed unlinking bucket on error cleanup: " << cpp_strerror(-r) << dendl; @@ -3044,17 +3047,17 @@ done_err: int RGWBucketCtl::unlink_bucket(const rgw_user& user_id, const rgw_bucket& bucket, optional_yield y, bool update_entrypoint) { return bm_handler->call([&](RGWSI_Bucket_EP_Ctx& ctx) { - return do_unlink_bucket(ctx, user_id, bucket, y, update_entrypoint); + return do_unlink_bucket(ctx, user_id, bucket, update_entrypoint, y); }); } int RGWBucketCtl::do_unlink_bucket(RGWSI_Bucket_EP_Ctx& ctx, const rgw_user& user_id, const rgw_bucket& bucket, - optional_yield y, - bool update_entrypoint) + bool update_entrypoint, + optional_yield y) { - int ret = ctl.user->remove_bucket(user_id, bucket); + int ret = ctl.user->remove_bucket(user_id, bucket, y); if (ret < 0) { ldout(cct, 0) << "ERROR: error removing bucket from directory: " << cpp_strerror(-ret)<< dendl; @@ -3218,6 +3221,7 @@ int RGWBucketCtl::read_buckets_stats(map& m, int RGWBucketCtl::sync_user_stats(const rgw_user& user_id, const RGWBucketInfo& bucket_info, + optional_yield y, RGWBucketEnt* pent) { RGWBucketEnt ent; @@ -3230,7 +3234,7 @@ int RGWBucketCtl::sync_user_stats(const rgw_user& user_id, return r; } - return ctl.user->flush_bucket_stats(user_id, *pent); + return ctl.user->flush_bucket_stats(user_id, *pent, y); } int RGWBucketCtl::get_sync_policy_handler(std::optional zone, diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index e12ba2670d4..ef70037ef5b 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -229,7 +229,8 @@ extern int rgw_read_user_buckets(rgw::sal::RGWRadosStore *store, const string& marker, const string& end_marker, uint64_t max, - bool need_stats); + bool need_stats, + optional_yield y); extern int rgw_remove_object(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, rgw_obj_key& key); extern int rgw_remove_bucket_bypass_gc(rgw::sal::RGWRadosStore *store, rgw_bucket& bucket, int concurrent_max, optional_yield y); @@ -238,7 +239,7 @@ extern int rgw_object_get_attr(rgw::sal::RGWRadosStore* store, const RGWBucketIn const rgw_obj& obj, const char* attr_name, bufferlist& out_bl, optional_yield y); -extern void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, bool fix); +extern void check_bad_user_bucket_mapping(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, bool fix, optional_yield y); struct RGWBucketAdminOpState { rgw_user uid; @@ -395,10 +396,10 @@ public: static int remove_bucket(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, optional_yield y, bool bypass_gc = false, bool keep_index_consistent = true); static int remove_object(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state); - static int info(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher); + static int info(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y); static int limit_check(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state, const std::list& user_ids, - RGWFormatterFlusher& flusher, + RGWFormatterFlusher& flusher, optional_yield y, bool warnings_only = false); static int set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOpState& op_state); @@ -704,6 +705,7 @@ public: /* quota related */ int sync_user_stats(const rgw_user& user_id, const RGWBucketInfo& bucket_info, + optional_yield y, RGWBucketEnt* pent = nullptr); /* bucket sync */ @@ -740,15 +742,15 @@ private: const rgw_user& user, const rgw_bucket& bucket, ceph::real_time creation_time, - optional_yield y, bool update_entrypoint, - rgw_ep_info *pinfo); + rgw_ep_info *pinfo, + optional_yield y); int do_unlink_bucket(RGWSI_Bucket_EP_Ctx& ctx, const rgw_user& user_id, const rgw_bucket& bucket, - optional_yield y, - bool update_entrypoint); + bool update_entrypoint, + optional_yield y); }; diff --git a/src/rgw/rgw_cr_tools.cc b/src/rgw/rgw_cr_tools.cc index 8b4e49e37f7..a5a84742bec 100644 --- a/src/rgw/rgw_cr_tools.cc +++ b/src/rgw/rgw_cr_tools.cc @@ -160,8 +160,8 @@ int RGWBucketCreateLocalCR::Request::_send_request() bucket.tenant = user.tenant; bucket.name = bucket_name; ret = zone_svc->select_bucket_placement(*user_info, zonegroup_id, - placement_rule, - &selected_placement_rule, nullptr); + placement_rule, + &selected_placement_rule, nullptr, null_yield); if (selected_placement_rule != bucket_info.placement_rule) { ldout(cct, 0) << "bucket already exists on a different placement rule: " << " selected_rule= " << selected_placement_rule @@ -194,7 +194,7 @@ int RGWBucketCreateLocalCR::Request::_send_request() placement_rule, bucket_info.swift_ver_location, pquota_info, attrs, info, nullptr, &ep_objv, creation_time, - pmaster_bucket, pmaster_num_shards, true); + pmaster_bucket, pmaster_num_shards, null_yield, true); if (ret && ret != -EEXIST) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 0e26e12e820..67555de83df 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1621,7 +1621,7 @@ namespace rgw { return -EIO; } - op_ret = state->bucket->check_quota(user_quota, bucket_quota, real_ofs, true); + op_ret = state->bucket->check_quota(user_quota, bucket_quota, real_ofs, null_yield, true); /* max_size exceed */ if (op_ret < 0) return -EIO; @@ -1663,7 +1663,7 @@ namespace rgw { goto done; } - op_ret = state->bucket->check_quota(user_quota, bucket_quota, state->obj_size, true); + op_ret = state->bucket->check_quota(user_quota, bucket_quota, state->obj_size, null_yield, true); /* max_size exceed */ if (op_ret < 0) { goto done; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 58f4d040b1d..10b2806c497 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2325,7 +2325,7 @@ void RGWListBuckets::execute() read_count = max_buckets; } - op_ret = s->user->list_buckets(marker, end_marker, read_count, should_get_stats(), buckets); + op_ret = s->user->list_buckets(marker, end_marker, read_count, should_get_stats(), buckets, null_yield); if (op_ret < 0) { /* hmm.. something wrong here.. the user was authenticated, so it @@ -2428,19 +2428,19 @@ void RGWGetUsage::execute() } } - op_ret = rgw_user_sync_all_stats(store, s->user->get_id()); + op_ret = rgw_user_sync_all_stats(store, s->user->get_id(), null_yield); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: failed to sync user stats" << dendl; return; } - op_ret = rgw_user_get_all_buckets_stats(store, s->user->get_id(), buckets_usage); + op_ret = rgw_user_get_all_buckets_stats(store, s->user->get_id(), buckets_usage, null_yield); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: failed to get user's buckets stats" << dendl; return; } - op_ret = store->ctl()->user->read_stats(s->user->get_id(), &stats); + op_ret = store->ctl()->user->read_stats(s->user->get_id(), &stats, null_yield); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: can't read user header" << dendl; return; @@ -2469,7 +2469,7 @@ void RGWStatAccount::execute() lastmarker = nullptr; op_ret = rgw_read_user_buckets(store, s->user->get_id(), buckets, marker, - string(), max_buckets, true); + string(), max_buckets, true, null_yield); if (op_ret < 0) { /* hmm.. something wrong here.. the user was authenticated, so it should exist */ @@ -2870,7 +2870,7 @@ int RGWCreateBucket::verify_permission() string marker; op_ret = rgw_read_user_buckets(store, s->user->get_id(), buckets, marker, string(), s->user->get_max_buckets(), - false); + false, null_yield); if (op_ret < 0) { return op_ret; } @@ -3179,7 +3179,7 @@ void RGWCreateBucket::execute() info.swift_ver_location, pquota_info, policy, attrs, info, ep_objv, true, obj_lock_enabled, &s->bucket_exists, s->info, - &s->bucket); + &s->bucket, null_yield); /* continue if EEXIST and create_bucket will fail below. this way we can * recover from a partial create by retrying it. */ @@ -3317,7 +3317,7 @@ void RGWDeleteBucket::execute() } } - op_ret = s->bucket->sync_user_stats(); + op_ret = s->bucket->sync_user_stats(null_yield); if ( op_ret < 0) { ldpp_dout(this, 1) << "WARNING: failed to sync user stats before bucket delete: op_ret= " << op_ret << dendl; } @@ -3768,7 +3768,7 @@ void RGWPutObj::execute() if (!chunked_upload) { /* with chunked upload we don't know how big is the upload. we also check sizes at the end anyway */ - op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length, null_yield); if (op_ret < 0) { ldpp_dout(this, 20) << "check_quota() returned ret=" << op_ret << dendl; return; @@ -3978,7 +3978,7 @@ void RGWPutObj::execute() return; } - op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size, null_yield); if (op_ret < 0) { ldpp_dout(this, 20) << "second check_quota() returned op_ret=" << op_ret << dendl; return; @@ -4162,7 +4162,7 @@ void RGWPostObj::execute() ceph::buffer::list bl, aclbl; int len = 0; - op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length, null_yield); if (op_ret < 0) { return; } @@ -4267,7 +4267,7 @@ void RGWPostObj::execute() s->object->set_obj_size(ofs); - op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size, null_yield); if (op_ret < 0) { return; } @@ -5174,7 +5174,7 @@ void RGWCopyObj::execute() } // enforce quota against the destination bucket owner op_ret = dest_bucket->check_quota(user_quota, bucket_quota, - astate->accounted_size); + astate->accounted_size, null_yield); if (op_ret < 0) { return; } @@ -6827,7 +6827,7 @@ int RGWBulkUploadOp::handle_dir_verify_permission() std::string marker; op_ret = rgw_read_user_buckets(store, s->user->get_user(), buckets, marker, std::string(), s->user->get_max_buckets(), - false); + false, null_yield); if (op_ret < 0) { return op_ret; } @@ -6910,7 +6910,7 @@ int RGWBulkUploadOp::handle_dir(const std::string_view path) pquota_info, policy, attrs, out_info, ep_objv, true, false, &bucket_exists, - info, &bucket); + info, &bucket, null_yield); /* continue if EEXIST and create_bucket will fail below. this way we can * recover from a partial create by retrying it. */ ldpp_dout(this, 20) << "rgw_create_bucket returned ret=" << op_ret @@ -7028,7 +7028,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path, return op_ret; } - op_ret = bucket->check_quota(user_quota, bucket_quota, size); + op_ret = bucket->check_quota(user_quota, bucket_quota, size, null_yield); if (op_ret < 0) { return op_ret; } @@ -7108,7 +7108,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path, return op_ret; } - op_ret = bucket->check_quota(user_quota, bucket_quota, size); + op_ret = bucket->check_quota(user_quota, bucket_quota, size, null_yield); if (op_ret < 0) { ldpp_dout(this, 20) << "quota exceeded for path=" << path << dendl; return op_ret; diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index cc0754f61ed..49ec8f10517 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -65,7 +65,7 @@ protected: } }; - virtual int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats) = 0; + virtual int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y) = 0; virtual bool map_find(const rgw_user& user, const rgw_bucket& bucket, RGWQuotaCacheStats& qs) = 0; @@ -81,7 +81,7 @@ public: async_refcount->put_wait(); /* wait for all pending async requests to complete */ } - int get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota); + int get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota, optional_yield y); void adjust_stats(const rgw_user& user, rgw_bucket& bucket, int objs_delta, uint64_t added_bytes, uint64_t removed_bytes); virtual bool can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& stats); @@ -196,7 +196,7 @@ void RGWQuotaCache::set_stats(const rgw_user& user, const rgw_bucket& bucket, } template -int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota) { +int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota, optional_yield y) { RGWQuotaCacheStats qs; utime_t now = ceph_clock_now(); if (map_find(user, bucket, qs)) { @@ -216,7 +216,7 @@ int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, } } - int ret = fetch_stats_from_storage(user, bucket, stats); + int ret = fetch_stats_from_storage(user, bucket, stats, y); if (ret < 0 && ret != -ENOENT) return ret; @@ -351,7 +351,7 @@ protected: stats_map.add(bucket, qs); } - int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats) override; + int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y) override; public: explicit RGWBucketStatsCache(rgw::sal::RGWRadosStore *_store) : RGWQuotaCache(_store, _store->ctx()->_conf->rgw_bucket_quota_cache_size) { @@ -362,13 +362,13 @@ public: } }; -int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats) +int RGWBucketStatsCache::fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y) { RGWBucketInfo bucket_info; RGWSysObjectCtx obj_ctx = store->svc()->sysobj->init_obj_ctx(); - int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL, null_yield); + int r = store->getRados()->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL, y); if (r < 0) { ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << " r=" << r << dendl; return r; @@ -466,7 +466,7 @@ class RGWUserStatsCache : public RGWQuotaCache { rgw_bucket bucket = iter->first; rgw_user& user = iter->second; ldout(cct, 20) << "BucketsSyncThread: sync user=" << user << " bucket=" << bucket << dendl; - int r = stats->sync_bucket(user, bucket); + int r = stats->sync_bucket(user, bucket, null_yield); if (r < 0) { ldout(cct, 0) << "WARNING: sync_bucket() returned r=" << r << dendl; } @@ -511,7 +511,7 @@ class RGWUserStatsCache : public RGWQuotaCache { void *entry() override { ldout(cct, 20) << "UserSyncThread: start" << dendl; do { - int ret = stats->sync_all_users(); + int ret = stats->sync_all_users(null_yield); if (ret < 0) { ldout(cct, 5) << "ERROR: sync_all_users() returned ret=" << ret << dendl; } @@ -548,10 +548,10 @@ protected: stats_map.add(user, qs); } - int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats) override; - int sync_bucket(const rgw_user& rgw_user, rgw_bucket& bucket); - int sync_user(const rgw_user& user); - int sync_all_users(); + int fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y) override; + int sync_bucket(const rgw_user& rgw_user, rgw_bucket& bucket, optional_yield y); + int sync_user(const rgw_user& user, optional_yield y); + int sync_all_users(optional_yield y); void data_modified(const rgw_user& user, rgw_bucket& bucket) override; @@ -615,9 +615,12 @@ public: } }; -int RGWUserStatsCache::fetch_stats_from_storage(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats) +int RGWUserStatsCache::fetch_stats_from_storage(const rgw_user& user, + const rgw_bucket& bucket, + RGWStorageStats& stats, + optional_yield y) { - int r = store->ctl()->user->read_stats(user, &stats); + int r = store->ctl()->user->read_stats(user, &stats, y); if (r < 0) { ldout(store->ctx(), 0) << "could not get user stats for user=" << user << dendl; return r; @@ -626,18 +629,18 @@ int RGWUserStatsCache::fetch_stats_from_storage(const rgw_user& user, const rgw_ return 0; } -int RGWUserStatsCache::sync_bucket(const rgw_user& user, rgw_bucket& bucket) +int RGWUserStatsCache::sync_bucket(const rgw_user& user, rgw_bucket& bucket, optional_yield y) { RGWBucketInfo bucket_info; - int r = store->ctl()->bucket->read_bucket_instance_info(bucket, &bucket_info, null_yield); + int r = store->ctl()->bucket->read_bucket_instance_info(bucket, &bucket_info, y); if (r < 0) { ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << " r=" << r << dendl; return r; } RGWBucketEnt ent; - r = store->ctl()->bucket->sync_user_stats(user, bucket_info, &ent); + r = store->ctl()->bucket->sync_user_stats(user, bucket_info, y, &ent); if (r < 0) { ldout(store->ctx(), 0) << "ERROR: sync_user_stats() for user=" << user << ", bucket=" << bucket << " returned " << r << dendl; return r; @@ -646,14 +649,14 @@ int RGWUserStatsCache::sync_bucket(const rgw_user& user, rgw_bucket& bucket) return store->getRados()->check_bucket_shards(bucket_info, bucket, ent.count); } -int RGWUserStatsCache::sync_user(const rgw_user& user) +int RGWUserStatsCache::sync_user(const rgw_user& user, optional_yield y) { string user_str = user.to_str(); RGWStorageStats stats; ceph::real_time last_stats_sync; ceph::real_time last_stats_update; - int ret = store->ctl()->user->read_stats(rgw_user(user_str), &stats, &last_stats_sync, &last_stats_update); + int ret = store->ctl()->user->read_stats(rgw_user(user_str), &stats, y, &last_stats_sync, &last_stats_update); if (ret < 0) { ldout(store->ctx(), 5) << "ERROR: can't read user header: ret=" << ret << dendl; return ret; @@ -671,7 +674,7 @@ int RGWUserStatsCache::sync_user(const rgw_user& user) // check if enough time passed since last full sync /* FIXME: missing check? */ - ret = rgw_user_sync_all_stats(store, user); + ret = rgw_user_sync_all_stats(store, user, y); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: failed user stats sync, ret=" << ret << dendl; return ret; @@ -680,7 +683,7 @@ int RGWUserStatsCache::sync_user(const rgw_user& user) return 0; } -int RGWUserStatsCache::sync_all_users() +int RGWUserStatsCache::sync_all_users(optional_yield y) { string key = "user"; void *handle; @@ -706,7 +709,7 @@ int RGWUserStatsCache::sync_all_users() ++iter) { rgw_user user(*iter); ldout(store->ctx(), 20) << "RGWUserStatsCache: sync user=" << user << dendl; - int ret = sync_user(user); + int ret = sync_user(user, y); if (ret < 0) { ldout(store->ctx(), 5) << "ERROR: sync_user() failed, user=" << user << " ret=" << ret << dendl; @@ -924,11 +927,11 @@ public: user_stats_cache(_store, quota_threads) {} int check_quota(const rgw_user& user, - rgw_bucket& bucket, - RGWQuotaInfo& user_quota, - RGWQuotaInfo& bucket_quota, - uint64_t num_objs, - uint64_t size) override { + rgw_bucket& bucket, + RGWQuotaInfo& user_quota, + RGWQuotaInfo& bucket_quota, + uint64_t num_objs, + uint64_t size, optional_yield y) override { if (!bucket_quota.enabled && !user_quota.enabled) { return 0; @@ -944,7 +947,7 @@ public: if (bucket_quota.enabled) { RGWStorageStats bucket_stats; int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, - bucket_quota); + bucket_quota, y); if (ret < 0) { return ret; } @@ -956,7 +959,8 @@ public: if (user_quota.enabled) { RGWStorageStats user_stats; - int ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota); + int ret = user_stats_cache.get_stats(user, bucket, user_stats, + user_quota, y); if (ret < 0) { return ret; } diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index ece795207cd..6901aa913a5 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -22,6 +22,9 @@ #include +#include "rgw/rgw_basic_types.h" +#include "common/async/yield_context.h" + static inline int64_t rgw_rounded_kb(int64_t bytes) { return (bytes + 1023) / 1024; @@ -105,7 +108,7 @@ public: } virtual int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, - uint64_t num_objs, uint64_t size) = 0; + uint64_t num_objs, uint64_t size, optional_yield y) = 0; virtual void check_bucket_shards(uint64_t max_objs_per_shard, uint64_t num_shards, uint64_t num_objs, bool& need_resharding, uint32_t *suggested_num_shards) = 0; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index dcef286757c..44bfcea027e 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1334,10 +1334,10 @@ int RGWRados::init_complete() int RGWRados::init_svc(bool raw) { if (raw) { - return svc.init_raw(cct, use_cache); + return svc.init_raw(cct, use_cache, null_yield); } - return svc.init(cct, use_cache, run_sync_thread); + return svc.init(cct, use_cache, run_sync_thread, null_yield); } int RGWRados::init_ctl() @@ -2200,6 +2200,7 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, real_time creation_time, rgw_bucket *pmaster_bucket, uint32_t *pmaster_num_shards, + optional_yield y, bool exclusive) { #define MAX_CREATE_RETRIES 20 /* need to bound retries */ @@ -2209,7 +2210,7 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, for (int i = 0; i < MAX_CREATE_RETRIES; i++) { int ret = 0; ret = svc.zone->select_bucket_placement(owner, zonegroup_id, placement_rule, - &selected_placement_rule, &rule_info); + &selected_placement_rule, &rule_info, y); if (ret < 0) return ret; @@ -9045,13 +9046,15 @@ int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info, uint32_t n } int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only) + RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, + uint64_t obj_size, optional_yield y, + bool check_size_only) { // if we only check size, then num_objs will set to 0 if(check_size_only) - return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 0, obj_size); + return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 0, obj_size, y); - return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size); + return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size, y); } int RGWRados::get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key, diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5bd30e374e9..1fb788fe8c4 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -662,18 +662,19 @@ public: bool obj_to_raw(const rgw_placement_rule& placement_rule, const rgw_obj& obj, rgw_raw_obj *raw_obj); int create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, - const string& zonegroup_id, - const rgw_placement_rule& placement_rule, - const string& swift_ver_location, - const RGWQuotaInfo * pquota_info, - map& attrs, - RGWBucketInfo& bucket_info, - obj_version *pobjv, - obj_version *pep_objv, - ceph::real_time creation_time, - rgw_bucket *master_bucket, - uint32_t *master_num_shards, - bool exclusive = true); + const string& zonegroup_id, + const rgw_placement_rule& placement_rule, + const string& swift_ver_location, + const RGWQuotaInfo * pquota_info, + map& attrs, + RGWBucketInfo& bucket_info, + obj_version *pobjv, + obj_version *pep_objv, + ceph::real_time creation_time, + rgw_bucket *master_bucket, + uint32_t *master_num_shards, + optional_yield y, + bool exclusive = true); RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; } @@ -1461,7 +1462,8 @@ public: int fix_tail_obj_locator(const RGWBucketInfo& bucket_info, rgw_obj_key& key, bool fix, bool *need_fix, optional_yield y); int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false); + RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, + optional_yield y, bool check_size_only = false); int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, uint64_t num_objs); diff --git a/src/rgw/rgw_rest_bucket.cc b/src/rgw/rgw_rest_bucket.cc index 80f4d20363b..cc8cdd1c70e 100644 --- a/src/rgw/rgw_rest_bucket.cc +++ b/src/rgw/rgw_rest_bucket.cc @@ -48,7 +48,7 @@ void RGWOp_Bucket_Info::execute() op_state.set_bucket_name(bucket); op_state.set_fetch_stats(fetch_stats); - op_ret = RGWBucketAdminOp::info(store, op_state, flusher); + op_ret = RGWBucketAdminOp::info(store, op_state, flusher, null_yield); } class RGWOp_Get_Policy : public RGWRESTOp { diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index 9eb36c84123..b38979dbe4c 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -119,7 +119,7 @@ void RGWOp_MDLog_List::send_response() { void RGWOp_MDLog_Info::execute() { num_objects = s->cct->_conf->rgw_md_log_max_shards; - period = store->svc()->mdlog->read_oldest_log_period(); + period = store->svc()->mdlog->read_oldest_log_period(null_yield); op_ret = period.get_error(); } diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index 64195354800..7f3621d3768 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -89,7 +89,7 @@ void RGWOp_User_Info::execute() op_state.set_fetch_stats(fetch_stats); op_state.set_sync_stats(sync_stats); - op_ret = RGWUserAdminOp_User::info(store, op_state, flusher); + op_ret = RGWUserAdminOp_User::info(store, op_state, flusher, null_yield); } class RGWOp_User_Create : public RGWRESTOp { @@ -372,7 +372,7 @@ void RGWOp_User_Modify::execute() ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; } - op_ret = RGWUserAdminOp_User::modify(store, op_state, flusher); + op_ret = RGWUserAdminOp_User::modify(store, op_state, flusher, null_yield); } class RGWOp_User_Remove : public RGWRESTOp { @@ -556,7 +556,7 @@ void RGWOp_Subuser_Modify::execute() ldpp_dout(this, 0) << "forward_request_to_master returned ret=" << op_ret << dendl; return; } - op_ret = RGWUserAdminOp_Subuser::modify(store, op_state, flusher); + op_ret = RGWUserAdminOp_Subuser::modify(store, op_state, flusher, null_yield); } class RGWOp_Subuser_Remove : public RGWRESTOp { @@ -1051,7 +1051,7 @@ void RGWOp_Quota_Set::execute() } string err; - op_ret = user.modify(op_state, &err); + op_ret = user.modify(op_state, null_yield, &err); if (op_ret < 0) { ldout(store->ctx(), 20) << "failed updating user info: " << op_ret << ": " << err << dendl; return; diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index fc7dd911fe9..054f893354c 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -69,7 +69,8 @@ class RGWStore : public DoutPrefixProvider { bool obj_lock_enabled, bool *existed, req_info& req_info, - std::unique_ptr* bucket) = 0; + std::unique_ptr* bucket, + optional_yield y) = 0; virtual RGWBucketList* list_buckets(void) = 0; virtual bool is_meta_master() = 0; virtual int forward_request_to_master(RGWUser* user, obj_version *objv, @@ -95,7 +96,8 @@ class RGWUser { virtual ~RGWUser() = default; virtual int list_buckets(const std::string& marker, const std::string& end_marker, - uint64_t max, bool need_stats, RGWBucketList& buckets) = 0; + uint64_t max, bool need_stats, RGWBucketList& buckets, + optional_yield y) = 0; virtual RGWBucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time) = 0; friend class RGWBucket; virtual std::string& get_display_name() { return info.display_name; } @@ -194,7 +196,7 @@ class RGWBucket { std::string *max_marker = nullptr, bool *syncstopped = nullptr) = 0; virtual int read_bucket_stats(optional_yield y) = 0; - virtual int sync_user_stats() = 0; + virtual int sync_user_stats(optional_yield y) = 0; virtual int update_container_stats(void) = 0; virtual int check_bucket_shards(void) = 0; virtual int link(RGWUser* new_user, optional_yield y) = 0; @@ -203,7 +205,7 @@ class RGWBucket { virtual int put_instance_info(bool exclusive, ceph::real_time mtime) = 0; virtual bool is_owner(RGWUser* user) = 0; virtual int check_empty(optional_yield y) = 0; - virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false) = 0; + virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0; virtual int set_instance_attrs(RGWAttrs& attrs, optional_yield y) = 0; virtual int try_refresh_info(ceph::real_time *pmtime) = 0; virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 122d6358826..5d92ab6f3d9 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -39,7 +39,8 @@ namespace rgw::sal { int RGWRadosUser::list_buckets(const string& marker, const string& end_marker, - uint64_t max, bool need_stats, RGWBucketList &buckets) + uint64_t max, bool need_stats, RGWBucketList &buckets, + optional_yield y) { RGWUserBuckets ulist; bool is_truncated = false; @@ -47,7 +48,7 @@ int RGWRadosUser::list_buckets(const string& marker, const string& end_marker, buckets.clear(); ret = store->ctl()->user->list_buckets(info.user_id, marker, end_marker, max, - need_stats, &ulist, &is_truncated); + need_stats, &ulist, &is_truncated, y); if (ret < 0) return ret; @@ -129,8 +130,8 @@ int RGWRadosBucket::remove_bucket(bool delete_children, std::string prefix, std: } } - ret = store->ctl()->bucket->sync_user_stats(info.owner, info); - if ( ret < 0) { + ret = store->ctl()->bucket->sync_user_stats(info.owner, info, y); + if (ret < 0) { ldout(store->ctx(), 1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; } @@ -213,9 +214,9 @@ int RGWRadosBucket::read_bucket_stats(optional_yield y) return ret; } -int RGWRadosBucket::sync_user_stats() +int RGWRadosBucket::sync_user_stats(optional_yield y) { - return store->ctl()->bucket->sync_user_stats(owner->get_id(), info); + return store->ctl()->bucket->sync_user_stats(owner->get_id(), info, y); } int RGWRadosBucket::update_container_stats(void) @@ -295,10 +296,11 @@ int RGWRadosBucket::check_empty(optional_yield y) return store->getRados()->check_bucket_empty(info, y); } -int RGWRadosBucket::check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only) +int RGWRadosBucket::check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, + optional_yield y, bool check_size_only) { return store->getRados()->check_quota(owner->get_user(), get_key(), - user_quota, bucket_quota, obj_size, check_size_only); + user_quota, bucket_quota, obj_size, y, check_size_only); } int RGWRadosBucket::set_instance_attrs(RGWAttrs& attrs, optional_yield y) @@ -837,7 +839,8 @@ int RGWRadosStore::create_bucket(RGWUser& u, const rgw_bucket& b, bool obj_lock_enabled, bool *existed, req_info& req_info, - std::unique_ptr* bucket_out) + std::unique_ptr* bucket_out, + optional_yield y) { int ret; bufferlist in_data; @@ -909,8 +912,8 @@ int RGWRadosStore::create_bucket(RGWUser& u, const rgw_bucket& b, if (*existed) { rgw_placement_rule selected_placement_rule; ret = svc()->zone->select_bucket_placement(u.get_info(), - zid, placement_rule, - &selected_placement_rule, nullptr); + zid, placement_rule, + &selected_placement_rule, nullptr, y); if (selected_placement_rule != info.placement_rule) { ret = -EEXIST; bucket_out->swap(bucket); @@ -922,7 +925,7 @@ int RGWRadosStore::create_bucket(RGWUser& u, const rgw_bucket& b, zid, placement_rule, swift_ver_location, pquota_info, attrs, info, pobjv, &ep_objv, creation_time, - pmaster_bucket, pmaster_num_shards, exclusive); + pmaster_bucket, pmaster_num_shards, y, exclusive); if (ret == -EEXIST) { *existed = true; ret = 0; diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 4c1ad186c08..06fca75ccfe 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -33,7 +33,8 @@ class RGWRadosUser : public RGWUser { RGWRadosUser() {} int list_buckets(const std::string& marker, const std::string& end_marker, - uint64_t max, bool need_stats, RGWBucketList& buckets); + uint64_t max, bool need_stats, RGWBucketList& buckets, + optional_yield y) override; RGWBucket* create_bucket(rgw_bucket& bucket, ceph::real_time creation_time); /* Placeholders */ @@ -194,7 +195,7 @@ class RGWRadosBucket : public RGWBucket { std::string *max_marker = nullptr, bool *syncstopped = nullptr) override; virtual int read_bucket_stats(optional_yield y) override; - virtual int sync_user_stats() override; + virtual int sync_user_stats(optional_yield y) override; virtual int update_container_stats(void) override; virtual int check_bucket_shards(void) override; virtual int link(RGWUser* new_user, optional_yield y) override; @@ -203,7 +204,7 @@ class RGWRadosBucket : public RGWBucket { virtual int put_instance_info(bool exclusive, ceph::real_time mtime) override; virtual bool is_owner(RGWUser* user) override; virtual int check_empty(optional_yield y) override; - virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false) override; + virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) override; virtual int set_instance_attrs(RGWAttrs& attrs, optional_yield y) override; virtual int try_refresh_info(ceph::real_time *pmtime) override; virtual int read_usage(uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, @@ -247,7 +248,8 @@ class RGWRadosStore : public RGWStore { bool obj_lock_enabled, bool *existed, req_info& req_info, - std::unique_ptr* bucket); + std::unique_ptr* bucket, + optional_yield y); virtual RGWBucketList* list_buckets(void) { return new RGWBucketList(); } virtual bool is_meta_master() override; virtual int forward_request_to_master(RGWUser* user, obj_version *objv, diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index fd98711ca6f..3fb4f2b0b64 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -37,7 +37,6 @@ #define dout_subsys ceph_subsys_rgw - RGWServices_Def::RGWServices_Def() = default; RGWServices_Def::~RGWServices_Def() { @@ -47,7 +46,8 @@ RGWServices_Def::~RGWServices_Def() int RGWServices_Def::init(CephContext *cct, bool have_cache, bool raw, - bool run_sync) + bool run_sync, + optional_yield y) { finisher = std::make_unique(cct); bucket_sobj = std::make_unique(cct); @@ -113,28 +113,28 @@ int RGWServices_Def::init(CephContext *cct, can_shutdown = true; - int r = finisher->start(); + int r = finisher->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start finisher service (" << cpp_strerror(-r) << dendl; return r; } if (!raw) { - r = notify->start(); + r = notify->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start notify service (" << cpp_strerror(-r) << dendl; return r; } } - r = rados->start(); + r = rados->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start rados service (" << cpp_strerror(-r) << dendl; return r; } if (!raw) { - r = zone->start(); + r = zone->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start zone service (" << cpp_strerror(-r) << dendl; return r; @@ -148,95 +148,95 @@ int RGWServices_Def::init(CephContext *cct, return r; } - r = mdlog->start(); + r = mdlog->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start mdlog service (" << cpp_strerror(-r) << dendl; return r; } - r = sync_modules->start(); + r = sync_modules->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start sync modules service (" << cpp_strerror(-r) << dendl; return r; } } - r = cls->start(); + r = cls->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start cls service (" << cpp_strerror(-r) << dendl; return r; } - r = config_key_rados->start(); + r = config_key_rados->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start config_key service (" << cpp_strerror(-r) << dendl; return r; } - r = zone_utils->start(); + r = zone_utils->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start zone_utils service (" << cpp_strerror(-r) << dendl; return r; } - r = quota->start(); + r = quota->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start quota service (" << cpp_strerror(-r) << dendl; return r; } - r = sysobj_core->start(); + r = sysobj_core->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start sysobj_core service (" << cpp_strerror(-r) << dendl; return r; } if (have_cache) { - r = sysobj_cache->start(); + r = sysobj_cache->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start sysobj_cache service (" << cpp_strerror(-r) << dendl; return r; } } - r = sysobj->start(); + r = sysobj->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start sysobj service (" << cpp_strerror(-r) << dendl; return r; } if (!raw) { - r = meta_be_sobj->start(); + r = meta_be_sobj->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start meta_be_sobj service (" << cpp_strerror(-r) << dendl; return r; } - r = meta->start(); + r = meta->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start meta service (" << cpp_strerror(-r) << dendl; return r; } - r = bucket_sobj->start(); + r = bucket_sobj->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start bucket service (" << cpp_strerror(-r) << dendl; return r; } - r = bucket_sync_sobj->start(); + r = bucket_sync_sobj->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start bucket_sync service (" << cpp_strerror(-r) << dendl; return r; } - r = user_rados->start(); + r = user_rados->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start user_rados service (" << cpp_strerror(-r) << dendl; return r; } - r = otp->start(); + r = otp->start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start otp service (" << cpp_strerror(-r) << dendl; return r; @@ -274,11 +274,11 @@ void RGWServices_Def::shutdown() } -int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_sync) +int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_sync, optional_yield y) { cct = _cct; - int r = _svc.init(cct, have_cache, raw, run_sync); + int r = _svc.init(cct, have_cache, raw, run_sync, y); if (r < 0) { return r; } @@ -314,7 +314,7 @@ int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_ return 0; } -int RGWServiceInstance::start() +int RGWServiceInstance::start(optional_yield y) { if (start_state != StateInit) { return 0; @@ -323,7 +323,7 @@ int RGWServiceInstance::start() start_state = StateStarting;; /* setting started prior to do_start() on purpose so that circular references can call start() on each other */ - int r = do_start(); + int r = do_start(y); if (r < 0) { return r; } diff --git a/src/rgw/rgw_service.h b/src/rgw/rgw_service.h index fc3fbe7266b..36a3fed618d 100644 --- a/src/rgw/rgw_service.h +++ b/src/rgw/rgw_service.h @@ -9,6 +9,8 @@ #include #include +#include "common/async/yield_context.h" + #include "rgw/rgw_common.h" struct RGWServices_Def; @@ -27,14 +29,14 @@ protected: } start_state{StateInit}; virtual void shutdown() {} - virtual int do_start() { + virtual int do_start(optional_yield) { return 0; } public: RGWServiceInstance(CephContext *_cct) : cct(_cct) {} virtual ~RGWServiceInstance() {} - int start(); + int start(optional_yield y); bool is_started() { return (start_state == StateStarted); } @@ -106,7 +108,7 @@ struct RGWServices_Def RGWServices_Def(); ~RGWServices_Def(); - int init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync); + int init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y); void shutdown(); }; @@ -145,14 +147,14 @@ struct RGWServices RGWSI_SysObj_Core *core{nullptr}; RGWSI_User *user{nullptr}; - int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync); + int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync, optional_yield y); - int init(CephContext *cct, bool have_cache, bool run_sync) { - return do_init(cct, have_cache, false, run_sync); + int init(CephContext *cct, bool have_cache, bool run_sync, optional_yield y) { + return do_init(cct, have_cache, false, run_sync, y); } - int init_raw(CephContext *cct, bool have_cache) { - return do_init(cct, have_cache, true, false); + int init_raw(CephContext *cct, bool have_cache, optional_yield y) { + return do_init(cct, have_cache, true, false, y); } void shutdown() { _svc.shutdown(); diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 59ae19686d1..3a2b70088fb 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -48,7 +48,8 @@ void rgw_get_anon_user(RGWUserInfo& info) info.access_keys.clear(); } -int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user_id) +int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, + const rgw_user& user_id, optional_yield y) { rgw::sal::RGWBucketList user_buckets; rgw::sal::RGWRadosUser user(store, user_id); @@ -59,7 +60,7 @@ int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user int ret; do { - ret = user.list_buckets(marker, string(), max_entries, false, user_buckets); + ret = user.list_buckets(marker, string(), max_entries, false, user_buckets, y); if (ret < 0) { ldout(cct, 0) << "failed to read user buckets: ret=" << ret << dendl; return ret; @@ -75,7 +76,7 @@ int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user ldout(cct, 0) << "ERROR: could not read bucket info: bucket=" << bucket << " ret=" << ret << dendl; continue; } - ret = bucket->sync_user_stats(); + ret = bucket->sync_user_stats(y); if (ret < 0) { ldout(cct, 0) << "ERROR: could not sync bucket stats: ret=" << ret << dendl; return ret; @@ -87,7 +88,7 @@ int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user } } while (user_buckets.is_truncated()); - ret = store->ctl()->user->complete_flush_stats(user.get_user()); + ret = store->ctl()->user->complete_flush_stats(user.get_user(), y); if (ret < 0) { cerr << "ERROR: failed to complete syncing user stats: ret=" << ret << std::endl; return ret; @@ -96,7 +97,10 @@ int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user return 0; } -int rgw_user_get_all_buckets_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, map& buckets_usage_map) +int rgw_user_get_all_buckets_stats(rgw::sal::RGWRadosStore *store, + const rgw_user& user_id, + map& buckets_usage_map, + optional_yield y) { CephContext *cct = store->ctx(); size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk; @@ -107,7 +111,7 @@ int rgw_user_get_all_buckets_stats(rgw::sal::RGWRadosStore *store, const rgw_use do { rgw::sal::RGWBucketList buckets; ret = rgw_read_user_buckets(store, user_id, buckets, marker, - string(), max_entries, false); + string(), max_entries, false, y); if (ret < 0) { ldout(cct, 0) << "failed to read user buckets: ret=" << ret << dendl; return ret; @@ -1180,7 +1184,7 @@ int RGWSubUserPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg, return 0; } -int RGWSubUserPool::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_user_update) +int RGWSubUserPool::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_user_update, optional_yield y) { int ret = 0; std::string subprocess_msg; @@ -1226,12 +1230,12 @@ int RGWSubUserPool::execute_modify(RGWUserAdminOpState& op_state, std::string *e return 0; } -int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg) +int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg) { - return RGWSubUserPool::modify(op_state, err_msg, false); + return RGWSubUserPool::modify(op_state, y, err_msg, false); } -int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_user_update) +int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg, bool defer_user_update) { std::string subprocess_msg; int ret; @@ -1244,7 +1248,7 @@ int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg, return ret; } - ret = execute_modify(op_state, &subprocess_msg, defer_user_update); + ret = execute_modify(op_state, &subprocess_msg, defer_user_update, y); if (ret < 0) { set_err_msg(err_msg, "unable to modify subuser, " + subprocess_msg); return ret; @@ -1580,7 +1584,7 @@ static void rename_swift_keys(const rgw_user& user, } } -int RGWUser::execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg) +int RGWUser::execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg, optional_yield y) { int ret; bool populated = op_state.is_populated(); @@ -1636,7 +1640,7 @@ int RGWUser::execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg) rgw::sal::RGWBucketList buckets; do { - ret = old_user.list_buckets(marker, "", max_buckets, false, buckets); + ret = old_user.list_buckets(marker, "", max_buckets, false, buckets, y); if (ret < 0) { set_err_msg(err_msg, "unable to list user buckets"); return ret; @@ -1836,7 +1840,7 @@ int RGWUser::add(RGWUserAdminOpState& op_state, std::string *err_msg) return 0; } -int RGWUser::rename(RGWUserAdminOpState& op_state, std::string *err_msg) +int RGWUser::rename(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg) { std::string subprocess_msg; int ret; @@ -1847,7 +1851,7 @@ int RGWUser::rename(RGWUserAdminOpState& op_state, std::string *err_msg) return ret; } - ret = execute_rename(op_state, &subprocess_msg); + ret = execute_rename(op_state, &subprocess_msg, y); if (ret < 0) { set_err_msg(err_msg, "unable to rename user, " + subprocess_msg); return ret; @@ -1875,7 +1879,7 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg, size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk; do { ret = rgw_read_user_buckets(store, uid, buckets, marker, string(), - max_buckets, false); + max_buckets, false, y); if (ret < 0) { set_err_msg(err_msg, "unable to read user bucket info"); return ret; @@ -1933,7 +1937,7 @@ int RGWUser::remove(RGWUserAdminOpState& op_state, optional_yield y, std::string return 0; } -int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) +int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, optional_yield y) { bool populated = op_state.is_populated(); int ret = 0; @@ -2030,7 +2034,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) size_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk; do { ret = rgw_read_user_buckets(store, user_id, buckets, marker, string(), - max_buckets, false); + max_buckets, false, y); if (ret < 0) { set_err_msg(err_msg, "could not get buckets for uid: " + user_id.to_str()); return ret; @@ -2085,7 +2089,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) return 0; } -int RGWUser::modify(RGWUserAdminOpState& op_state, std::string *err_msg) +int RGWUser::modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg) { std::string subprocess_msg; int ret; @@ -2096,7 +2100,7 @@ int RGWUser::modify(RGWUserAdminOpState& op_state, std::string *err_msg) return ret; } - ret = execute_modify(op_state, &subprocess_msg); + ret = execute_modify(op_state, &subprocess_msg, y); if (ret < 0) { set_err_msg(err_msg, "unable to modify user, " + subprocess_msg); return ret; @@ -2204,7 +2208,8 @@ int RGWUserAdminOp_User::list(rgw::sal::RGWRadosStore *store, RGWUserAdminOpStat } int RGWUserAdminOp_User::info(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, - RGWFormatterFlusher& flusher) + RGWFormatterFlusher& flusher, + optional_yield y) { RGWUserInfo info; RGWUser user; @@ -2223,7 +2228,7 @@ int RGWUserAdminOp_User::info(rgw::sal::RGWRadosStore *store, RGWUserAdminOpStat return ret; if (op_state.sync_stats) { - ret = rgw_user_sync_all_stats(store, info.user_id); + ret = rgw_user_sync_all_stats(store, info.user_id, y); if (ret < 0) { return ret; } @@ -2232,7 +2237,7 @@ int RGWUserAdminOp_User::info(rgw::sal::RGWRadosStore *store, RGWUserAdminOpStat RGWStorageStats stats; RGWStorageStats *arg_stats = NULL; if (op_state.fetch_stats) { - int ret = store->ctl()->user->read_stats(info.user_id, &stats); + int ret = store->ctl()->user->read_stats(info.user_id, &stats, y); if (ret < 0 && ret != -ENOENT) { return ret; } @@ -2283,7 +2288,7 @@ int RGWUserAdminOp_User::create(rgw::sal::RGWRadosStore *store, RGWUserAdminOpSt } int RGWUserAdminOp_User::modify(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, - RGWFormatterFlusher& flusher) + RGWFormatterFlusher& flusher, optional_yield y) { RGWUserInfo info; RGWUser user; @@ -2292,7 +2297,7 @@ int RGWUserAdminOp_User::modify(rgw::sal::RGWRadosStore *store, RGWUserAdminOpSt return ret; Formatter *formatter = flusher.get_formatter(); - ret = user.modify(op_state, NULL); + ret = user.modify(op_state, y, NULL); if (ret < 0) { if (ret == -ENOENT) ret = -ERR_NO_SUCH_USER; @@ -2363,7 +2368,7 @@ int RGWUserAdminOp_Subuser::create(rgw::sal::RGWRadosStore *store, RGWUserAdminO } int RGWUserAdminOp_Subuser::modify(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, - RGWFormatterFlusher& flusher) + RGWFormatterFlusher& flusher, optional_yield y) { RGWUserInfo info; RGWUser user; @@ -2376,7 +2381,7 @@ int RGWUserAdminOp_Subuser::modify(rgw::sal::RGWRadosStore *store, RGWUserAdminO Formatter *formatter = flusher.get_formatter(); - ret = user.subusers.modify(op_state, NULL); + ret = user.subusers.modify(op_state, y, NULL); if (ret < 0) return ret; @@ -2795,20 +2800,22 @@ int RGWUserCtl::remove_info(const RGWUserInfo& info, optional_yield y, int RGWUserCtl::add_bucket(const rgw_user& user, const rgw_bucket& bucket, - ceph::real_time creation_time) + ceph::real_time creation_time, + optional_yield y) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.user->add_bucket(op->ctx(), user, bucket, creation_time); + return svc.user->add_bucket(op->ctx(), user, bucket, creation_time, y); }); } int RGWUserCtl::remove_bucket(const rgw_user& user, - const rgw_bucket& bucket) + const rgw_bucket& bucket, + optional_yield y) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.user->remove_bucket(op->ctx(), user, bucket); + return svc.user->remove_bucket(op->ctx(), user, bucket, y); }); } @@ -2819,6 +2826,7 @@ int RGWUserCtl::list_buckets(const rgw_user& user, bool need_stats, RGWUserBuckets *buckets, bool *is_truncated, + optional_yield y, uint64_t default_max) { if (!max) { @@ -2827,7 +2835,7 @@ int RGWUserCtl::list_buckets(const rgw_user& user, return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { int ret = svc.user->list_buckets(op->ctx(), user, marker, end_marker, - max, buckets, is_truncated); + max, buckets, is_truncated, y); if (ret < 0) { return ret; } @@ -2844,34 +2852,36 @@ int RGWUserCtl::list_buckets(const rgw_user& user, } int RGWUserCtl::flush_bucket_stats(const rgw_user& user, - const RGWBucketEnt& ent) + const RGWBucketEnt& ent, + optional_yield y) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.user->flush_bucket_stats(op->ctx(), user, ent); + return svc.user->flush_bucket_stats(op->ctx(), user, ent, y); }); } -int RGWUserCtl::complete_flush_stats(const rgw_user& user) +int RGWUserCtl::complete_flush_stats(const rgw_user& user, optional_yield y) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.user->complete_flush_stats(op->ctx(), user); + return svc.user->complete_flush_stats(op->ctx(), user, y); }); } -int RGWUserCtl::reset_stats(const rgw_user& user) +int RGWUserCtl::reset_stats(const rgw_user& user, optional_yield y) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { - return svc.user->reset_bucket_stats(op->ctx(), user); + return svc.user->reset_bucket_stats(op->ctx(), user, y); }); } int RGWUserCtl::read_stats(const rgw_user& user, RGWStorageStats *stats, + optional_yield y, ceph::real_time *last_stats_sync, ceph::real_time *last_stats_update) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->read_stats(op->ctx(), user, stats, - last_stats_sync, last_stats_update); + last_stats_sync, last_stats_update, y); }); } diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index 3e84230434c..c038ea873b5 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -57,8 +57,10 @@ struct RGWUID }; WRITE_CLASS_ENCODER(RGWUID) -extern int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user_id); -extern int rgw_user_get_all_buckets_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, map&buckets_usage_map); +extern int rgw_user_sync_all_stats(rgw::sal::RGWRadosStore *store, const rgw_user& user_id, optional_yield y); +extern int rgw_user_get_all_buckets_stats( + rgw::sal::RGWRadosStore *store,const rgw_user& user_id, + map& buckets_usage_map, optional_yield y); /** * Get the anonymous (ie, unauthenticated) user info. @@ -626,11 +628,11 @@ private: /* API Contract Fulfillment */ int execute_add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); int execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); - int execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); + int execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save, optional_yield y); int add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); int remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); - int modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); + int modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg, bool defer_save); public: explicit RGWSubUserPool(RGWUser *user); @@ -640,7 +642,7 @@ public: /* API contracted methods */ int add(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); int remove(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); - int modify(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); + int modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg = NULL); friend class RGWUser; }; @@ -692,8 +694,8 @@ private: int execute_add(RGWUserAdminOpState& op_state, std::string *err_msg); int execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg, optional_yield y); - int execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg); - int execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg); + int execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg, optional_yield y); + int execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg, optional_yield y); public: RGWUser(); @@ -717,12 +719,12 @@ public: int remove(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg = NULL); - int rename(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); + int rename(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg = NULL); /* remove an already populated RGWUser */ int remove(std::string *err_msg = NULL); - int modify(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); + int modify(RGWUserAdminOpState& op_state, optional_yield y, std::string *err_msg = NULL); /* retrieve info from an existing user in the RGW system */ int info(RGWUserAdminOpState& op_state, RGWUserInfo& fetched_info, std::string *err_msg = NULL); @@ -747,13 +749,14 @@ public: RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); static int info(rgw::sal::RGWRadosStore *store, - RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); + RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, + optional_yield y); static int create(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); static int modify(rgw::sal::RGWRadosStore *store, - RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); + RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y); static int remove(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, optional_yield y); @@ -766,7 +769,8 @@ public: RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); static int modify(rgw::sal::RGWRadosStore *store, - RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); + RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher, + optional_yield y); static int remove(rgw::sal::RGWRadosStore *store, RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher); @@ -952,9 +956,10 @@ public: int add_bucket(const rgw_user& user, const rgw_bucket& bucket, - ceph::real_time creation_time); + ceph::real_time creation_time, + optional_yield y); int remove_bucket(const rgw_user& user, - const rgw_bucket& bucket); + const rgw_bucket& bucket, optional_yield y); int list_buckets(const rgw_user& user, const string& marker, const string& end_marker, @@ -962,13 +967,16 @@ public: bool need_stats, RGWUserBuckets *buckets, bool *is_truncated, + optional_yield y, uint64_t default_max = 1000); int flush_bucket_stats(const rgw_user& user, - const RGWBucketEnt& ent); - int complete_flush_stats(const rgw_user& user); - int reset_stats(const rgw_user& user); + const RGWBucketEnt& ent, + optional_yield y); + int complete_flush_stats(const rgw_user& user, optional_yield y); + int reset_stats(const rgw_user& user, optional_yield y); int read_stats(const rgw_user& user, RGWStorageStats *stats, + optional_yield y, ceph::real_time *last_stats_sync = nullptr, /* last time a full stats sync completed */ ceph::real_time *last_stats_update = nullptr); /* last time a stats update was done */ int read_stats_async(const rgw_user& user, RGWGetUserStats_CB *ctx); diff --git a/src/rgw/services/svc_bilog_rados.cc b/src/rgw/services/svc_bilog_rados.cc index e741b20e028..13368e24d6c 100644 --- a/src/rgw/services/svc_bilog_rados.cc +++ b/src/rgw/services/svc_bilog_rados.cc @@ -177,11 +177,12 @@ int RGWSI_BILog_RADOS::log_list(const RGWBucketInfo& bucket_info, int shard_id, int RGWSI_BILog_RADOS::get_log_status(const RGWBucketInfo& bucket_info, int shard_id, - map *markers) + map *markers, + optional_yield y) { vector headers; map bucket_instance_ids; - int r = svc.bi->cls_bucket_head(bucket_info, shard_id, &headers, &bucket_instance_ids, null_yield); + int r = svc.bi->cls_bucket_head(bucket_info, shard_id, &headers, &bucket_instance_ids, y); if (r < 0) return r; diff --git a/src/rgw/services/svc_bilog_rados.h b/src/rgw/services/svc_bilog_rados.h index 5aad9fe8c08..2691d209253 100644 --- a/src/rgw/services/svc_bilog_rados.h +++ b/src/rgw/services/svc_bilog_rados.h @@ -51,6 +51,7 @@ public: int get_log_status(const RGWBucketInfo& bucket_info, int shard_id, - map *markers); + map *markers, + optional_yield y); }; diff --git a/src/rgw/services/svc_bucket_sobj.cc b/src/rgw/services/svc_bucket_sobj.cc index 9d77f5b430f..8dea5461d11 100644 --- a/src/rgw/services/svc_bucket_sobj.cc +++ b/src/rgw/services/svc_bucket_sobj.cc @@ -159,7 +159,7 @@ void RGWSI_Bucket_SObj::init(RGWSI_Zone *_zone_svc, RGWSI_SysObj *_sysobj_svc, svc.bucket_sync = _bucket_sync_svc; } -int RGWSI_Bucket_SObj::do_start() +int RGWSI_Bucket_SObj::do_start(optional_yield) { binfo_cache.reset(new RGWChainedCacheImpl); binfo_cache->init(svc.cache); diff --git a/src/rgw/services/svc_bucket_sobj.h b/src/rgw/services/svc_bucket_sobj.h index 744f4a8931e..10e134d5b24 100644 --- a/src/rgw/services/svc_bucket_sobj.h +++ b/src/rgw/services/svc_bucket_sobj.h @@ -51,7 +51,7 @@ class RGWSI_Bucket_SObj : public RGWSI_Bucket RGWSI_BucketInstance_BE_Handler bi_be_handler; std::unique_ptr bi_be_module; - int do_start() override; + int do_start(optional_yield) override; int do_read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, const string& key, diff --git a/src/rgw/services/svc_bucket_sync_sobj.cc b/src/rgw/services/svc_bucket_sync_sobj.cc index ec3152b43c0..f80b9618bb9 100644 --- a/src/rgw/services/svc_bucket_sync_sobj.cc +++ b/src/rgw/services/svc_bucket_sync_sobj.cc @@ -59,7 +59,7 @@ void RGWSI_Bucket_Sync_SObj::init(RGWSI_Zone *_zone_svc, hint_index_mgr.reset(new RGWSI_Bucket_Sync_SObj_HintIndexManager(svc.zone, svc.sysobj)); } -int RGWSI_Bucket_Sync_SObj::do_start() +int RGWSI_Bucket_Sync_SObj::do_start(optional_yield) { sync_policy_cache.reset(new RGWChainedCacheImpl); sync_policy_cache->init(svc.cache); diff --git a/src/rgw/services/svc_bucket_sync_sobj.h b/src/rgw/services/svc_bucket_sync_sobj.h index 912259b137d..49f764881ca 100644 --- a/src/rgw/services/svc_bucket_sync_sobj.h +++ b/src/rgw/services/svc_bucket_sync_sobj.h @@ -43,7 +43,7 @@ class RGWSI_Bucket_Sync_SObj : public RGWSI_Bucket_Sync std::unique_ptr hint_index_mgr; - int do_start() override; + int do_start(optional_yield) override; struct optional_zone_bucket { optional zone; diff --git a/src/rgw/services/svc_cls.cc b/src/rgw/services/svc_cls.cc index 68501922a87..984d92a5ee9 100644 --- a/src/rgw/services/svc_cls.cc +++ b/src/rgw/services/svc_cls.cc @@ -17,9 +17,9 @@ static string log_lock_name = "rgw_log_lock"; -int RGWSI_Cls::do_start() +int RGWSI_Cls::do_start(optional_yield y) { - int r = mfa.do_start(); + int r = mfa.do_start(y); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start mfa service" << dendl; return r; diff --git a/src/rgw/services/svc_cls.h b/src/rgw/services/svc_cls.h index 58e05db16a3..80674a286bc 100644 --- a/src/rgw/services/svc_cls.h +++ b/src/rgw/services/svc_cls.h @@ -152,6 +152,6 @@ public: lock.init(this, zone_svc, rados_svc); } - int do_start() override; + int do_start(optional_yield) override; }; diff --git a/src/rgw/services/svc_config_key_rados.cc b/src/rgw/services/svc_config_key_rados.cc index 96997123902..7a16b22f0bb 100644 --- a/src/rgw/services/svc_config_key_rados.cc +++ b/src/rgw/services/svc_config_key_rados.cc @@ -2,7 +2,7 @@ #include "svc_rados.h" #include "svc_config_key_rados.h" -int RGWSI_ConfigKey_RADOS::do_start() +int RGWSI_ConfigKey_RADOS::do_start(optional_yield) { maybe_insecure_mon_conn = !svc.rados->check_secure_mon_conn(); diff --git a/src/rgw/services/svc_config_key_rados.h b/src/rgw/services/svc_config_key_rados.h index 1bd560564db..d7997364fb6 100644 --- a/src/rgw/services/svc_config_key_rados.h +++ b/src/rgw/services/svc_config_key_rados.h @@ -31,7 +31,7 @@ class RGWSI_ConfigKey_RADOS : public RGWSI_ConfigKey bool maybe_insecure_mon_conn{false}; std::atomic_flag warned_insecure = ATOMIC_FLAG_INIT; - int do_start() override; + int do_start(optional_yield) override; void warn_if_insecure(); diff --git a/src/rgw/services/svc_finisher.cc b/src/rgw/services/svc_finisher.cc index 5ae4fbd6169..70938ecac10 100644 --- a/src/rgw/services/svc_finisher.cc +++ b/src/rgw/services/svc_finisher.cc @@ -5,7 +5,7 @@ #include "svc_finisher.h" -int RGWSI_Finisher::do_start() +int RGWSI_Finisher::do_start(optional_yield) { finisher = new Finisher(cct); finisher->start(); diff --git a/src/rgw/services/svc_finisher.h b/src/rgw/services/svc_finisher.h index 346d0c3a657..9ce22dbce4a 100644 --- a/src/rgw/services/svc_finisher.h +++ b/src/rgw/services/svc_finisher.h @@ -25,7 +25,7 @@ private: protected: void init() {} - int do_start() override; + int do_start(optional_yield y) override; public: RGWSI_Finisher(CephContext *cct): RGWServiceInstance(cct) {} diff --git a/src/rgw/services/svc_mdlog.cc b/src/rgw/services/svc_mdlog.cc index e98d1f566c5..9e76258a692 100644 --- a/src/rgw/services/svc_mdlog.cc +++ b/src/rgw/services/svc_mdlog.cc @@ -38,7 +38,7 @@ int RGWSI_MDLog::init(RGWSI_RADOS *_rados_svc, RGWSI_Zone *_zone_svc, RGWSI_SysO return 0; } -int RGWSI_MDLog::do_start() +int RGWSI_MDLog::do_start(optional_yield y) { auto& current_period = svc.zone->get_current_period(); @@ -51,19 +51,20 @@ int RGWSI_MDLog::do_start() if (run_sync && svc.zone->need_to_sync()) { // initialize the log period history - svc.mdlog->init_oldest_log_period(); + svc.mdlog->init_oldest_log_period(y); } return 0; } int RGWSI_MDLog::read_history(RGWMetadataLogHistory *state, - RGWObjVersionTracker *objv_tracker) const + RGWObjVersionTracker *objv_tracker, + optional_yield y) const { auto obj_ctx = svc.sysobj->init_obj_ctx(); auto& pool = svc.zone->get_zone_params().log_pool; const auto& oid = RGWMetadataLogHistory::oid; bufferlist bl; - int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, objv_tracker, nullptr, null_yield); + int ret = rgw_get_system_obj(obj_ctx, pool, oid, bl, objv_tracker, nullptr, y); if (ret < 0) { return ret; } @@ -71,7 +72,7 @@ int RGWSI_MDLog::read_history(RGWMetadataLogHistory *state, /* bad history object, remove it */ rgw_raw_obj obj(pool, oid); auto sysobj = obj_ctx.get_obj(obj); - ret = sysobj.wop().remove(null_yield); + ret = sysobj.wop().remove(y); if (ret < 0) { ldout(cct, 0) << "ERROR: meta history is empty, but cannot remove it (" << cpp_strerror(-ret) << ")" << dendl; return ret; @@ -276,12 +277,12 @@ Cursor RGWSI_MDLog::find_oldest_period() return cursor; } -Cursor RGWSI_MDLog::init_oldest_log_period() +Cursor RGWSI_MDLog::init_oldest_log_period(optional_yield y) { // read the mdlog history RGWMetadataLogHistory state; RGWObjVersionTracker objv; - int ret = read_history(&state, &objv); + int ret = read_history(&state, &objv, y); if (ret == -ENOENT) { // initialize the mdlog history and write it @@ -345,10 +346,10 @@ Cursor RGWSI_MDLog::init_oldest_log_period() return period_history->attach(std::move(period)); } -Cursor RGWSI_MDLog::read_oldest_log_period() const +Cursor RGWSI_MDLog::read_oldest_log_period(optional_yield y) const { RGWMetadataLogHistory state; - int ret = read_history(&state, nullptr); + int ret = read_history(&state, nullptr, y); if (ret < 0) { ldout(cct, 1) << "failed to read mdlog history: " << cpp_strerror(ret) << dendl; diff --git a/src/rgw/services/svc_mdlog.h b/src/rgw/services/svc_mdlog.h index 7dbf80fe0bf..d8dec86bf82 100644 --- a/src/rgw/services/svc_mdlog.h +++ b/src/rgw/services/svc_mdlog.h @@ -71,7 +71,7 @@ public: RGWSI_SysObj *_sysobj_svc, RGWSI_Cls *_cls_svc); - int do_start() override; + int do_start(optional_yield y) override; // traverse all the way back to the beginning of the period history, and // return a cursor to the first period in a fully attached history @@ -79,11 +79,11 @@ public: /// initialize the oldest log period if it doesn't exist, and attach it to /// our current history - RGWPeriodHistory::Cursor init_oldest_log_period(); + RGWPeriodHistory::Cursor init_oldest_log_period(optional_yield y); /// read the oldest log period, and return a cursor to it in our existing /// period history - RGWPeriodHistory::Cursor read_oldest_log_period() const; + RGWPeriodHistory::Cursor read_oldest_log_period(optional_yield y) const; /// read the oldest log period asynchronously and write its result to the /// given cursor pointer @@ -94,7 +94,7 @@ public: /// using a rados lock to provide atomicity RGWCoroutine* trim_log_period_cr(RGWPeriodHistory::Cursor period, RGWObjVersionTracker *objv) const; - int read_history(RGWMetadataLogHistory *state, RGWObjVersionTracker *objv_tracker) const; + int read_history(RGWMetadataLogHistory *state, RGWObjVersionTracker *objv_tracker,optional_yield y) const; int write_history(const RGWMetadataLogHistory& state, RGWObjVersionTracker *objv_tracker, bool exclusive = false); diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index e6c0b58fbd2..e10ced4afe9 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -159,7 +159,7 @@ RGWSI_RADOS::Obj RGWSI_Notify::pick_control_obj(const string& key) return notify_objs[i]; } -int RGWSI_Notify::init_watch() +int RGWSI_Notify::init_watch(optional_yield y) { num_watchers = cct->_conf->rgw_num_control_oids; @@ -194,7 +194,7 @@ int RGWSI_Notify::init_watch() librados::ObjectWriteOperation op; op.create(false); - r = notify_obj.operate(&op, null_yield); + r = notify_obj.operate(&op, y); if (r < 0 && r != -EEXIST) { ldout(cct, 0) << "ERROR: notify_obj.operate() returned r=" << r << dendl; return r; @@ -237,27 +237,27 @@ void RGWSI_Notify::finalize_watch() delete[] watchers; } -int RGWSI_Notify::do_start() +int RGWSI_Notify::do_start(optional_yield y) { - int r = zone_svc->start(); + int r = zone_svc->start(y); if (r < 0) { return r; } assert(zone_svc->is_started()); /* otherwise there's an ordering problem */ - r = rados_svc->start(); + r = rados_svc->start(y); if (r < 0) { return r; } - r = finisher_svc->start(); + r = finisher_svc->start(y); if (r < 0) { return r; } control_pool = zone_svc->get_zone_params().control_pool; - int ret = init_watch(); + int ret = init_watch(y); if (ret < 0) { lderr(cct) << "ERROR: failed to initialize watch: " << cpp_strerror(-ret) << dendl; return ret; diff --git a/src/rgw/services/svc_notify.h b/src/rgw/services/svc_notify.h index 031c53120c0..567b256d064 100644 --- a/src/rgw/services/svc_notify.h +++ b/src/rgw/services/svc_notify.h @@ -53,7 +53,7 @@ private: bool finalized{false}; - int init_watch(); + int init_watch(optional_yield y); void finalize_watch(); void init(RGWSI_Zone *_zone_svc, @@ -63,7 +63,7 @@ private: rados_svc = _rados_svc; finisher_svc = _finisher_svc; } - int do_start() override; + int do_start(optional_yield) override; void shutdown() override; int unwatch(RGWSI_RADOS::Obj& obj, uint64_t watch_handle); diff --git a/src/rgw/services/svc_otp.cc b/src/rgw/services/svc_otp.cc index 595f13c9a0e..512c542eb2d 100644 --- a/src/rgw/services/svc_otp.cc +++ b/src/rgw/services/svc_otp.cc @@ -60,7 +60,7 @@ void RGWSI_OTP::init(RGWSI_Zone *_zone_svc, svc.meta_be = _meta_be_svc; } -int RGWSI_OTP::do_start() +int RGWSI_OTP::do_start(optional_yield) { /* create first backend handler for bucket entrypoints */ diff --git a/src/rgw/services/svc_otp.h b/src/rgw/services/svc_otp.h index f2d35ffefe8..76824bfdf43 100644 --- a/src/rgw/services/svc_otp.h +++ b/src/rgw/services/svc_otp.h @@ -31,7 +31,7 @@ class RGWSI_OTP : public RGWServiceInstance RGWSI_OTP_BE_Handler be_handler; std::unique_ptr be_module; - int do_start() override; + int do_start(optional_yield) override; public: struct Svc { diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 6a330e94203..1e1b12023f6 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -21,7 +21,7 @@ RGWSI_RADOS::~RGWSI_RADOS() { } -int RGWSI_RADOS::do_start() +int RGWSI_RADOS::do_start(optional_yield) { int ret = rados.init_with_context(cct); if (ret < 0) { diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index 88a2b473a71..b09cd6d73a9 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -31,7 +31,7 @@ class RGWSI_RADOS : public RGWServiceInstance librados::Rados rados; std::unique_ptr async_processor; - int do_start() override; + int do_start(optional_yield) override; public: struct OpenParams { diff --git a/src/rgw/services/svc_sync_modules.cc b/src/rgw/services/svc_sync_modules.cc index cf13139282e..f232fe5130a 100644 --- a/src/rgw/services/svc_sync_modules.cc +++ b/src/rgw/services/svc_sync_modules.cc @@ -16,7 +16,7 @@ void RGWSI_SyncModules::init(RGWSI_Zone *zone_svc) rgw_register_sync_modules(sync_modules_manager); } -int RGWSI_SyncModules::do_start() +int RGWSI_SyncModules::do_start(optional_yield) { auto& zone_public_config = svc.zone->get_zone(); diff --git a/src/rgw/services/svc_sync_modules.h b/src/rgw/services/svc_sync_modules.h index fbe86112d08..39a51f58091 100644 --- a/src/rgw/services/svc_sync_modules.h +++ b/src/rgw/services/svc_sync_modules.h @@ -28,7 +28,7 @@ public: } void init(RGWSI_Zone *zone_svc); - int do_start() override; + int do_start(optional_yield) override; RGWSyncModuleInstanceRef& get_sync_module() { return sync_module; } }; diff --git a/src/rgw/services/svc_sys_obj_cache.cc b/src/rgw/services/svc_sys_obj_cache.cc index 5407dace4c6..2402c3a4189 100644 --- a/src/rgw/services/svc_sys_obj_cache.cc +++ b/src/rgw/services/svc_sys_obj_cache.cc @@ -30,19 +30,19 @@ public: } }; -int RGWSI_SysObj_Cache::do_start() +int RGWSI_SysObj_Cache::do_start(optional_yield y) { int r = asocket.start(); if (r < 0) { return r; } - r = RGWSI_SysObj_Core::do_start(); + r = RGWSI_SysObj_Core::do_start(y); if (r < 0) { return r; } - r = notify_svc->start(); + r = notify_svc->start(y); if (r < 0) { return r; } diff --git a/src/rgw/services/svc_sys_obj_cache.h b/src/rgw/services/svc_sys_obj_cache.h index 54ba2cf1035..b2abb2f5505 100644 --- a/src/rgw/services/svc_sys_obj_cache.h +++ b/src/rgw/services/svc_sys_obj_cache.h @@ -33,7 +33,7 @@ protected: notify_svc = _notify_svc; } - int do_start() override; + int do_start(optional_yield) override; void shutdown() override; int raw_stat(const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, diff --git a/src/rgw/services/svc_user.h b/src/rgw/services/svc_user.h index 8b88fa13351..5c27e587c51 100644 --- a/src/rgw/services/svc_user.h +++ b/src/rgw/services/svc_user.h @@ -86,29 +86,33 @@ public: virtual int add_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, const rgw_bucket& bucket, - ceph::real_time creation_time) = 0; + ceph::real_time creation_time, + optional_yield y) = 0; virtual int remove_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const rgw_bucket& _bucket) = 0; + const rgw_bucket& _bucket, optional_yield) = 0; virtual int list_buckets(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, const string& marker, const string& end_marker, uint64_t max, RGWUserBuckets *buckets, - bool *is_truncated) = 0; + bool *is_truncated, + optional_yield y) = 0; virtual int flush_bucket_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const RGWBucketEnt& ent) = 0; + const RGWBucketEnt& ent, optional_yield y) = 0; virtual int complete_flush_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) = 0; + const rgw_user& user, optional_yield y) = 0; virtual int reset_bucket_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) = 0; + const rgw_user& user, + optional_yield y) = 0; virtual int read_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, RGWStorageStats *stats, ceph::real_time *last_stats_sync, /* last time a full stats sync completed */ - ceph::real_time *last_stats_update) = 0; /* last time a stats update was done */ + ceph::real_time *last_stats_update, + optional_yield y) = 0; /* last time a stats update was done */ virtual int read_stats_async(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, RGWGetUserStats_CB *cb) = 0; diff --git a/src/rgw/services/svc_user_rados.cc b/src/rgw/services/svc_user_rados.cc index 31d42588f68..14dcb6367f2 100644 --- a/src/rgw/services/svc_user_rados.cc +++ b/src/rgw/services/svc_user_rados.cc @@ -81,7 +81,7 @@ void RGWSI_User_RADOS::init(RGWSI_RADOS *_rados_svc, svc.sync_modules = _sync_modules_svc; } -int RGWSI_User_RADOS::do_start() +int RGWSI_User_RADOS::do_start(optional_yield) { uinfo_cache.reset(new RGWChainedCacheImpl); uinfo_cache->init(svc.cache); @@ -600,7 +600,7 @@ int RGWSI_User_RADOS::get_user_info_by_access_key(RGWSI_MetaBackend::Context *ct info, objv_tracker, pmtime, y); } -int RGWSI_User_RADOS::cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add) +int RGWSI_User_RADOS::cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add, optional_yield y) { auto rados_obj = svc.rados->obj(obj); int r = rados_obj.open(); @@ -610,7 +610,7 @@ int RGWSI_User_RADOS::cls_user_update_buckets(rgw_raw_obj& obj, list l; l.push_back(entry); - return cls_user_update_buckets(obj, l, true); + return cls_user_update_buckets(obj, l, true, y); } -int RGWSI_User_RADOS::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket) +int RGWSI_User_RADOS::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket, optional_yield y) { auto rados_obj = svc.rados->obj(obj); int r = rados_obj.open(); @@ -636,7 +636,7 @@ int RGWSI_User_RADOS::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bu librados::ObjectWriteOperation op; ::cls_user_remove_bucket(op, bucket); - r = rados_obj.operate(&op, null_yield); + r = rados_obj.operate(&op, y); if (r < 0) return r; @@ -646,7 +646,8 @@ int RGWSI_User_RADOS::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bu int RGWSI_User_RADOS::add_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, const rgw_bucket& bucket, - ceph::real_time creation_time) + ceph::real_time creation_time, + optional_yield y) { int ret; @@ -660,7 +661,7 @@ int RGWSI_User_RADOS::add_bucket(RGWSI_MetaBackend::Context *ctx, new_bucket.creation_time = creation_time; rgw_raw_obj obj = get_buckets_obj(user); - ret = cls_user_add_bucket(obj, new_bucket); + ret = cls_user_add_bucket(obj, new_bucket, y); if (ret < 0) { ldout(cct, 0) << "ERROR: error adding bucket to user: ret=" << ret << dendl; return ret; @@ -672,12 +673,13 @@ int RGWSI_User_RADOS::add_bucket(RGWSI_MetaBackend::Context *ctx, int RGWSI_User_RADOS::remove_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const rgw_bucket& _bucket) + const rgw_bucket& _bucket, + optional_yield y) { cls_user_bucket bucket; bucket.name = _bucket.name; rgw_raw_obj obj = get_buckets_obj(user); - int ret = cls_user_remove_bucket(obj, bucket); + int ret = cls_user_remove_bucket(obj, bucket, y); if (ret < 0) { ldout(cct, 0) << "ERROR: error removing bucket from user: ret=" << ret << dendl; } @@ -686,7 +688,7 @@ int RGWSI_User_RADOS::remove_bucket(RGWSI_MetaBackend::Context *ctx, } int RGWSI_User_RADOS::cls_user_flush_bucket_stats(rgw_raw_obj& user_obj, - const RGWBucketEnt& ent) + const RGWBucketEnt& ent, optional_yield y) { cls_user_bucket_entry entry; ent.convert(&entry); @@ -694,7 +696,7 @@ int RGWSI_User_RADOS::cls_user_flush_bucket_stats(rgw_raw_obj& user_obj, list entries; entries.push_back(entry); - int r = cls_user_update_buckets(user_obj, entries, false); + int r = cls_user_update_buckets(user_obj, entries, false, y); if (r < 0) { ldout(cct, 20) << "cls_user_update_buckets() returned " << r << dendl; return r; @@ -709,7 +711,8 @@ int RGWSI_User_RADOS::cls_user_list_buckets(rgw_raw_obj& obj, const int max_entries, list& entries, string * const out_marker, - bool * const truncated) + bool * const truncated, + optional_yield y) { auto rados_obj = svc.rados->obj(obj); int r = rados_obj.open(); @@ -722,7 +725,7 @@ int RGWSI_User_RADOS::cls_user_list_buckets(rgw_raw_obj& obj, cls_user_bucket_list(op, in_marker, end_marker, max_entries, entries, out_marker, truncated, &rc); bufferlist ibl; - r = rados_obj.operate(&op, &ibl, null_yield); + r = rados_obj.operate(&op, &ibl, y); if (r < 0) return r; if (rc < 0) @@ -732,12 +735,12 @@ int RGWSI_User_RADOS::cls_user_list_buckets(rgw_raw_obj& obj, } int RGWSI_User_RADOS::list_buckets(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user, - const string& marker, - const string& end_marker, - uint64_t max, - RGWUserBuckets *buckets, - bool *is_truncated) + const rgw_user& user, + const string& marker, + const string& end_marker, + uint64_t max, + RGWUserBuckets *buckets, + bool *is_truncated, optional_yield y) { int ret; @@ -746,7 +749,7 @@ int RGWSI_User_RADOS::list_buckets(RGWSI_MetaBackend::Context *ctx, ldout(cct, 20) << "RGWSI_User_RADOS::list_buckets(): anonymous user" << dendl; *is_truncated = false; return 0; - } + } rgw_raw_obj obj = get_buckets_obj(user); bool truncated = false; @@ -756,7 +759,7 @@ int RGWSI_User_RADOS::list_buckets(RGWSI_MetaBackend::Context *ctx, do { std::list entries; - ret = cls_user_list_buckets(obj, m, end_marker, max - total, entries, &m, &truncated); + ret = cls_user_list_buckets(obj, m, end_marker, max - total, entries, &m, &truncated, y); if (ret == -ENOENT) { ret = 0; } @@ -781,20 +784,22 @@ int RGWSI_User_RADOS::list_buckets(RGWSI_MetaBackend::Context *ctx, int RGWSI_User_RADOS::flush_bucket_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const RGWBucketEnt& ent) + const RGWBucketEnt& ent, + optional_yield y) { rgw_raw_obj obj = get_buckets_obj(user); - return cls_user_flush_bucket_stats(obj, ent); + return cls_user_flush_bucket_stats(obj, ent, y); } int RGWSI_User_RADOS::reset_bucket_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) + const rgw_user& user, + optional_yield y) { - return cls_user_reset_stats(user); + return cls_user_reset_stats(user, y); } -int RGWSI_User_RADOS::cls_user_reset_stats(const rgw_user& user) +int RGWSI_User_RADOS::cls_user_reset_stats(const rgw_user& user, optional_yield y) { rgw_raw_obj obj = get_buckets_obj(user); auto rados_obj = svc.rados->obj(obj); @@ -815,7 +820,7 @@ int RGWSI_User_RADOS::cls_user_reset_stats(const rgw_user& user) encode(call, in); op.exec("user", "reset_user_stats2", in, &out, &rval); - r = rados_obj.operate(&op, null_yield, librados::OPERATION_RETURNVEC); + r = rados_obj.operate(&op, y, librados::OPERATION_RETURNVEC); if (r < 0) { return r; } @@ -831,7 +836,7 @@ int RGWSI_User_RADOS::cls_user_reset_stats(const rgw_user& user) } int RGWSI_User_RADOS::complete_flush_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) + const rgw_user& user, optional_yield y) { rgw_raw_obj obj = get_buckets_obj(user); auto rados_obj = svc.rados->obj(obj); @@ -841,10 +846,11 @@ int RGWSI_User_RADOS::complete_flush_stats(RGWSI_MetaBackend::Context *ctx, } librados::ObjectWriteOperation op; ::cls_user_complete_stats_sync(op); - return rados_obj.operate(&op, null_yield); + return rados_obj.operate(&op, y); } -int RGWSI_User_RADOS::cls_user_get_header(const rgw_user& user, cls_user_header *header) +int RGWSI_User_RADOS::cls_user_get_header(const rgw_user& user, cls_user_header *header, + optional_yield y) { rgw_raw_obj obj = get_buckets_obj(user); auto rados_obj = svc.rados->obj(obj); @@ -856,7 +862,7 @@ int RGWSI_User_RADOS::cls_user_get_header(const rgw_user& user, cls_user_header bufferlist ibl; librados::ObjectReadOperation op; ::cls_user_get_header(op, header, &rc); - return rados_obj.operate(&op, &ibl, null_yield); + return rados_obj.operate(&op, &ibl, y); } int RGWSI_User_RADOS::cls_user_get_header_async(const string& user_str, RGWGetUserHeader_CB *cb) @@ -881,12 +887,13 @@ int RGWSI_User_RADOS::cls_user_get_header_async(const string& user_str, RGWGetUs int RGWSI_User_RADOS::read_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, RGWStorageStats *stats, ceph::real_time *last_stats_sync, - ceph::real_time *last_stats_update) + ceph::real_time *last_stats_update, + optional_yield y) { string user_str = user.to_str(); cls_user_header header; - int r = cls_user_get_header(rgw_user(user_str), &header); + int r = cls_user_get_header(rgw_user(user_str), &header, y); if (r < 0) return r; diff --git a/src/rgw/services/svc_user_rados.h b/src/rgw/services/svc_user_rados.h index 0939b101803..7014e3430ab 100644 --- a/src/rgw/services/svc_user_rados.h +++ b/src/rgw/services/svc_user_rados.h @@ -1,4 +1,3 @@ - // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab ft=cpp @@ -74,26 +73,27 @@ class RGWSI_User_RADOS : public RGWSI_User int remove_swift_name_index(RGWSI_MetaBackend::Context *ctx, const string& swift_name, optional_yield y); /* admin management */ - int cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add); - int cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry); - int cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket); + int cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add, optional_yield y); + int cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry, optional_yield y); + int cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket, optional_yield y); /* quota stats */ int cls_user_flush_bucket_stats(rgw_raw_obj& user_obj, - const RGWBucketEnt& ent); + const RGWBucketEnt& ent, optional_yield y); int cls_user_list_buckets(rgw_raw_obj& obj, const string& in_marker, const string& end_marker, const int max_entries, list& entries, string * const out_marker, - bool * const truncated); + bool * const truncated, + optional_yield y); - int cls_user_reset_stats(const rgw_user& user); - int cls_user_get_header(const rgw_user& user, cls_user_header *header); + int cls_user_reset_stats(const rgw_user& user, optional_yield y); + int cls_user_get_header(const rgw_user& user, cls_user_header *header, optional_yield y); int cls_user_get_header_async(const string& user, RGWGetUserHeader_CB *cb); - int do_start() override; + int do_start(optional_yield) override; public: struct Svc { RGWSI_User_RADOS *user{nullptr}; @@ -152,7 +152,7 @@ public: RGWUserInfo *info, /* out */ RGWObjVersionTracker * const objv_tracker, real_time * const pmtime, - optional_yield y); + optional_yield y) override; int get_user_info_by_access_key(RGWSI_MetaBackend::Context *ctx, const std::string& access_key, RGWUserInfo *info, @@ -165,32 +165,37 @@ public: int add_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, const rgw_bucket& bucket, - ceph::real_time creation_time) override; + ceph::real_time creation_time, + optional_yield y) override; int remove_bucket(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const rgw_bucket& _bucket) override; + const rgw_bucket& _bucket, + optional_yield y) override; int list_buckets(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, const string& marker, const string& end_marker, uint64_t max, RGWUserBuckets *buckets, - bool *is_truncated) override; + bool *is_truncated, + optional_yield y) override; /* quota related */ int flush_bucket_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, - const RGWBucketEnt& ent) override; + const RGWBucketEnt& ent, optional_yield y) override; int complete_flush_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) override; + const rgw_user& user, optional_yield y) override; int reset_bucket_stats(RGWSI_MetaBackend::Context *ctx, - const rgw_user& user) override; + const rgw_user& user, + optional_yield y) override; int read_stats(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, RGWStorageStats *stats, ceph::real_time *last_stats_sync, /* last time a full stats sync completed */ - ceph::real_time *last_stats_update) override; /* last time a stats update was done */ + ceph::real_time *last_stats_update, + optional_yield y) override; /* last time a stats update was done */ int read_stats_async(RGWSI_MetaBackend::Context *ctx, const rgw_user& user, RGWGetUserStats_CB *cb) override; diff --git a/src/rgw/services/svc_zone.cc b/src/rgw/services/svc_zone.cc index e32aff9b3c9..4c06121f36a 100644 --- a/src/rgw/services/svc_zone.cc +++ b/src/rgw/services/svc_zone.cc @@ -64,16 +64,16 @@ bool RGWSI_Zone::zone_syncs_from(const RGWZone& target_zone, const RGWZone& sour sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type); } -int RGWSI_Zone::do_start() +int RGWSI_Zone::do_start(optional_yield y) { - int ret = sysobj_svc->start(); + int ret = sysobj_svc->start(y); if (ret < 0) { return ret; } assert(sysobj_svc->is_started()); /* if not then there's ordering issue */ - ret = rados_svc->start(); + ret = rados_svc->start(y); if (ret < 0) { return ret; } @@ -92,13 +92,13 @@ int RGWSI_Zone::do_start() ldout(cct, 20) << "current period " << current_period->get_id() << dendl; } - ret = replace_region_with_zonegroup(); + ret = replace_region_with_zonegroup(y); if (ret < 0) { lderr(cct) << "failed converting region to zonegroup : ret "<< ret << " " << cpp_strerror(-ret) << dendl; return ret; } - ret = convert_regionmap(); + ret = convert_regionmap(y); if (ret < 0) { lderr(cct) << "failed converting regionmap: " << cpp_strerror(-ret) << dendl; return ret; @@ -170,7 +170,7 @@ int RGWSI_Zone::do_start() for (auto ziter : zonegroup->zones) { auto zone_handler = std::make_shared(this, sync_modules_svc, bucket_sync_svc, ziter.second.id); - ret = zone_handler->init(null_yield); + ret = zone_handler->init(y); if (ret < 0) { lderr(cct) << "ERROR: could not initialize zone policy handler for zone=" << ziter.second.name << dendl; return ret; @@ -189,7 +189,7 @@ int RGWSI_Zone::do_start() &target_zones, false); /* relaxed: also get all zones that we allow to sync to/from */ - ret = sync_modules_svc->start(); + ret = sync_modules_svc->start(y); if (ret < 0) { return ret; } @@ -343,7 +343,7 @@ int RGWSI_Zone::list_periods(const string& current_period, list& periods * backward compatability * Returns 0 on success, -ERR# on failure. */ -int RGWSI_Zone::replace_region_with_zonegroup() +int RGWSI_Zone::replace_region_with_zonegroup(optional_yield y) { /* copy default region */ /* convert default region to default zonegroup */ @@ -360,7 +360,7 @@ int RGWSI_Zone::replace_region_with_zonegroup() RGWSysObjectCtx obj_ctx = sysobj_svc->init_obj_ctx(); RGWSysObj sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid)); - int ret = sysobj.rop().read(&bl, null_yield); + int ret = sysobj.rop().read(&bl, y); if (ret < 0 && ret != -ENOENT) { ldout(cct, 0) << __func__ << " failed to read converted: ret "<< ret << " " << cpp_strerror(-ret) << dendl; @@ -584,7 +584,7 @@ int RGWSI_Zone::replace_region_with_zonegroup() /* mark as converted */ ret = sysobj.wop() .set_exclusive(true) - .write(bl, null_yield); + .write(bl, y); if (ret < 0 ) { ldout(cct, 0) << __func__ << " failed to mark cluster as converted: ret "<< ret << " " << cpp_strerror(-ret) << dendl; @@ -762,7 +762,7 @@ int RGWSI_Zone::init_zg_from_local(bool *creating_defaults) return 0; } -int RGWSI_Zone::convert_regionmap() +int RGWSI_Zone::convert_regionmap(optional_yield y) { RGWZoneGroupMap zonegroupmap; @@ -778,7 +778,7 @@ int RGWSI_Zone::convert_regionmap() RGWSysObjectCtx obj_ctx = sysobj_svc->init_obj_ctx(); RGWSysObj sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid)); - int ret = sysobj.rop().read(&bl, null_yield); + int ret = sysobj.rop().read(&bl, y); if (ret < 0 && ret != -ENOENT) { return ret; } else if (ret == -ENOENT) { @@ -816,7 +816,7 @@ int RGWSI_Zone::convert_regionmap() current_period->set_bucket_quota(zonegroupmap.bucket_quota); // remove the region_map so we don't try to convert again - ret = sysobj.wop().remove(null_yield); + ret = sysobj.wop().remove(y); if (ret < 0) { ldout(cct, 0) << "Error could not remove " << sysobj.get_obj() << " after upgrading to zonegroup map: " << cpp_strerror(ret) << dendl; @@ -997,8 +997,9 @@ bool RGWSI_Zone::is_syncing_bucket_meta(const rgw_bucket& bucket) int RGWSI_Zone::select_new_bucket_location(const RGWUserInfo& user_info, const string& zonegroup_id, - const rgw_placement_rule& request_rule, - rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info) + const rgw_placement_rule& request_rule, + rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info, + optional_yield y) { /* first check that zonegroup exists within current period. */ RGWZoneGroup zonegroup; @@ -1063,17 +1064,17 @@ int RGWSI_Zone::select_new_bucket_location(const RGWUserInfo& user_info, const s *pselected_rule_name = rule; } - return select_bucket_location_by_rule(rule, rule_info); + return select_bucket_location_by_rule(rule, rule_info, y); } -int RGWSI_Zone::select_bucket_location_by_rule(const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info) +int RGWSI_Zone::select_bucket_location_by_rule(const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info, optional_yield y) { if (location_rule.name.empty()) { /* we can only reach here if we're trying to set a bucket location from a bucket * created on a different zone, using a legacy / default pool configuration */ if (rule_info) { - return select_legacy_bucket_placement(rule_info); + return select_legacy_bucket_placement(rule_info, y); } return 0; @@ -1110,11 +1111,12 @@ int RGWSI_Zone::select_bucket_location_by_rule(const rgw_placement_rule& locatio int RGWSI_Zone::select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id, const rgw_placement_rule& placement_rule, - rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info) + rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info, + optional_yield y) { if (!zone_params->placement_pools.empty()) { return select_new_bucket_location(user_info, zonegroup_id, placement_rule, - pselected_rule, rule_info); + pselected_rule, rule_info, y); } if (pselected_rule) { @@ -1122,13 +1124,14 @@ int RGWSI_Zone::select_bucket_placement(const RGWUserInfo& user_info, const stri } if (rule_info) { - return select_legacy_bucket_placement(rule_info); + return select_legacy_bucket_placement(rule_info, y); } return 0; } -int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info) +int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info, + optional_yield y) { bufferlist map_bl; map m; @@ -1140,7 +1143,7 @@ int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info) auto obj_ctx = sysobj_svc->init_obj_ctx(); auto sysobj = obj_ctx.get_obj(obj); - int ret = sysobj.rop().read(&map_bl, null_yield); + int ret = sysobj.rop().read(&map_bl, y); if (ret < 0) { goto read_omap; } @@ -1154,7 +1157,7 @@ int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info) read_omap: if (m.empty()) { - ret = sysobj.omap().get_all(&m, null_yield); + ret = sysobj.omap().get_all(&m, y); write_map = true; } @@ -1168,7 +1171,7 @@ read_omap: ret = rados_svc->pool().create(pools, &retcodes); if (ret < 0) return ret; - ret = sysobj.omap().set(s, bl, null_yield); + ret = sysobj.omap().set(s, bl, y); if (ret < 0) return ret; m[s] = bl; @@ -1177,7 +1180,7 @@ read_omap: if (write_map) { bufferlist new_bl; encode(m, new_bl); - ret = sysobj.wop().write(new_bl, null_yield); + ret = sysobj.wop().write(new_bl, y); if (ret < 0) { ldout(cct, 0) << "WARNING: could not save avail pools map info ret=" << ret << dendl; } @@ -1201,7 +1204,7 @@ read_omap: return 0; } -int RGWSI_Zone::update_placement_map() +int RGWSI_Zone::update_placement_map(optional_yield y) { bufferlist header; map m; @@ -1210,13 +1213,13 @@ int RGWSI_Zone::update_placement_map() auto obj_ctx = sysobj_svc->init_obj_ctx(); auto sysobj = obj_ctx.get_obj(obj); - int ret = sysobj.omap().get_all(&m, null_yield); + int ret = sysobj.omap().get_all(&m, y); if (ret < 0) return ret; bufferlist new_bl; encode(m, new_bl); - ret = sysobj.wop().write(new_bl, null_yield); + ret = sysobj.wop().write(new_bl, y); if (ret < 0) { ldout(cct, 0) << "WARNING: could not save avail pools map info ret=" << ret << dendl; } @@ -1224,7 +1227,7 @@ int RGWSI_Zone::update_placement_map() return ret; } -int RGWSI_Zone::add_bucket_placement(const rgw_pool& new_pool) +int RGWSI_Zone::add_bucket_placement(const rgw_pool& new_pool, optional_yield y) { int ret = rados_svc->pool(new_pool).lookup(); if (ret < 0) { // DNE, or something @@ -1236,29 +1239,29 @@ int RGWSI_Zone::add_bucket_placement(const rgw_pool& new_pool) auto sysobj = obj_ctx.get_obj(obj); bufferlist empty_bl; - ret = sysobj.omap().set(new_pool.to_str(), empty_bl, null_yield); + ret = sysobj.omap().set(new_pool.to_str(), empty_bl, y); // don't care about return value - update_placement_map(); + update_placement_map(y); return ret; } -int RGWSI_Zone::remove_bucket_placement(const rgw_pool& old_pool) +int RGWSI_Zone::remove_bucket_placement(const rgw_pool& old_pool, optional_yield y) { rgw_raw_obj obj(zone_params->domain_root, avail_pools); auto obj_ctx = sysobj_svc->init_obj_ctx(); auto sysobj = obj_ctx.get_obj(obj); - int ret = sysobj.omap().del(old_pool.to_str(), null_yield); + int ret = sysobj.omap().del(old_pool.to_str(), y); // don't care about return value - update_placement_map(); + update_placement_map(y); return ret; } -int RGWSI_Zone::list_placement_set(set& names) +int RGWSI_Zone::list_placement_set(set& names, optional_yield y) { bufferlist header; map m; @@ -1266,7 +1269,7 @@ int RGWSI_Zone::list_placement_set(set& names) rgw_raw_obj obj(zone_params->domain_root, avail_pools); auto obj_ctx = sysobj_svc->init_obj_ctx(); auto sysobj = obj_ctx.get_obj(obj); - int ret = sysobj.omap().get_all(&m, null_yield); + int ret = sysobj.omap().get_all(&m, y); if (ret < 0) return ret; diff --git a/src/rgw/services/svc_zone.h b/src/rgw/services/svc_zone.h index 982ab8a8d27..0ad5a290a9b 100644 --- a/src/rgw/services/svc_zone.h +++ b/src/rgw/services/svc_zone.h @@ -58,18 +58,18 @@ class RGWSI_Zone : public RGWServiceInstance std::unique_ptr sync_policy; void init(RGWSI_SysObj *_sysobj_svc, - RGWSI_RADOS *_rados_svc, - RGWSI_SyncModules *_sync_modules_svc, - RGWSI_Bucket_Sync *_bucket_sync_svc); - int do_start() override; + RGWSI_RADOS *_rados_svc, + RGWSI_SyncModules *_sync_modules_svc, + RGWSI_Bucket_Sync *_bucket_sync_svc); + int do_start(optional_yield y) override; void shutdown() override; - int replace_region_with_zonegroup(); + int replace_region_with_zonegroup(optional_yield y); int init_zg_from_period(bool *initialized); int init_zg_from_local(bool *creating_defaults); - int convert_regionmap(); + int convert_regionmap(optional_yield y); - int update_placement_map(); + int update_placement_map(optional_yield y); public: RGWSI_Zone(CephContext *cct); ~RGWSI_Zone(); @@ -126,16 +126,17 @@ public: int select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id, const rgw_placement_rule& rule, - rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info); - int select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info); + rgw_placement_rule *pselected_rule, RGWZonePlacementInfo *rule_info, optional_yield y); + int select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info, optional_yield y); int select_new_bucket_location(const RGWUserInfo& user_info, const string& zonegroup_id, const rgw_placement_rule& rule, - rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info); - int select_bucket_location_by_rule(const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info); + rgw_placement_rule *pselected_rule_name, RGWZonePlacementInfo *rule_info, + optional_yield y); + int select_bucket_location_by_rule(const rgw_placement_rule& location_rule, RGWZonePlacementInfo *rule_info, optional_yield y); - int add_bucket_placement(const rgw_pool& new_pool); - int remove_bucket_placement(const rgw_pool& old_pool); - int list_placement_set(set& names); + int add_bucket_placement(const rgw_pool& new_pool, optional_yield y); + int remove_bucket_placement(const rgw_pool& old_pool, optional_yield y); + int list_placement_set(set& names, optional_yield y); bool is_meta_master() const; diff --git a/src/rgw/services/svc_zone_utils.cc b/src/rgw/services/svc_zone_utils.cc index 5cacd655e93..55e02e06100 100644 --- a/src/rgw/services/svc_zone_utils.cc +++ b/src/rgw/services/svc_zone_utils.cc @@ -7,7 +7,7 @@ #include "rgw/rgw_zone.h" -int RGWSI_ZoneUtils::do_start() +int RGWSI_ZoneUtils::do_start(optional_yield) { init_unique_trans_id_deps(); diff --git a/src/rgw/services/svc_zone_utils.h b/src/rgw/services/svc_zone_utils.h index 73702cbc75f..f596ec64754 100644 --- a/src/rgw/services/svc_zone_utils.h +++ b/src/rgw/services/svc_zone_utils.h @@ -24,7 +24,7 @@ class RGWSI_ZoneUtils : public RGWServiceInstance zone_svc = _zone_svc; } - int do_start() override; + int do_start(optional_yield) override; void init_unique_trans_id_deps(); diff --git a/src/test/rgw/test_rgw_lua.cc b/src/test/rgw/test_rgw_lua.cc index c3cffad6ab1..270b8a460ee 100644 --- a/src/test/rgw/test_rgw_lua.cc +++ b/src/test/rgw/test_rgw_lua.cc @@ -22,7 +22,7 @@ public: class TestRGWUser : public sal::RGWUser { public: - virtual int list_buckets(const string&, const string&, uint64_t, bool, sal::RGWBucketList&) override { + virtual int list_buckets(const string&, const string&, uint64_t, bool, sal::RGWBucketList&, optional_yield y) override { return 0; } diff --git a/src/test/rgw/test_rgw_throttle.cc b/src/test/rgw/test_rgw_throttle.cc index 5a520bf2a5d..a762a8c7a06 100644 --- a/src/test/rgw/test_rgw_throttle.cc +++ b/src/test/rgw/test_rgw_throttle.cc @@ -29,7 +29,7 @@ struct RadosEnv : public ::testing::Environment { void SetUp() override { rados.emplace(g_ceph_context); - ASSERT_EQ(0, rados->start()); + ASSERT_EQ(0, rados->start(null_yield)); int r = rados->pool({poolname}).create(); if (r == -EEXIST) r = 0; -- 2.39.5