map<uint32_t, rgw_data_sync_marker>& markers;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to read data sync status: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWReadDataSyncStatusMarkersCR(RGWDataSyncCtx *sc, int num_shards,
map<uint32_t, rgw_data_sync_marker>& markers)
string marker;
std::vector<RGWRadosGetOmapKeysCR::ResultPtr>& omapkeys;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to list recovering data sync: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWReadDataSyncRecoveringShardsCR(RGWDataSyncCtx *sc, uint64_t _max_entries, int _num_shards,
std::vector<RGWRadosGetOmapKeysCR::ResultPtr>& omapkeys)
int shard_id;
#define READ_DATALOG_MAX_CONCURRENT 10
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to fetch remote datalog info: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWReadRemoteDataLogInfoCR(RGWDataSyncCtx *_sc,
int _num_shards,
map<int, string>::iterator iter;
#define READ_DATALOG_MAX_CONCURRENT 10
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to list remote datalog: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWListRemoteDataLogCR(RGWDataSyncCtx *_sc,
map<int, string>& _shards,
using Vector = std::vector<rgw_bucket_shard_sync_info>;
Vector::iterator i, end;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to read bucket shard sync status: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWCollectBucketSyncStatusCR(rgw::sal::RadosStore* store, RGWDataSyncCtx *sc,
const RGWBucketInfo& source_bucket_info,
while (spawn_next()) {
current_running++;
- while (current_running >= max_concurrent) {
+ if (current_running >= max_concurrent) {
int child_ret;
yield wait_for_child();
if (collect_next(&child_ret)) {
current_running--;
- if (child_ret < 0 && child_ret != -ENOENT) {
- ldout(cct, 10) << __func__ << ": failed to fetch log status, ret=" << child_ret << dendl;
+ child_ret = handle_result(child_ret);
+ if (child_ret < 0) {
status = child_ret;
}
}
yield wait_for_child();
if (collect_next(&child_ret)) {
current_running--;
- if (child_ret < 0 && child_ret != -ENOENT) {
- ldout(cct, 10) << __func__ << ": failed to fetch log status, ret=" << child_ret << dendl;
+ child_ret = handle_result(child_ret);
+ if (child_ret < 0) {
status = child_ret;
}
}
int shard_id;
#define READ_MDLOG_MAX_CONCURRENT 10
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to fetch mdlog status: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWReadRemoteMDLogInfoCR(RGWMetaSyncEnv *_sync_env,
const std::string& period, int _num_shards,
map<int, string>::iterator iter;
#define READ_MDLOG_MAX_CONCURRENT 10
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to list remote mdlog shard: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWListRemoteMDLogCR(RGWMetaSyncEnv *_sync_env,
const std::string& period, map<int, string>& _shards,
int shard_id{0};
map<uint32_t, rgw_meta_sync_marker>& markers;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to read metadata sync markers: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
RGWReadSyncStatusMarkersCR(RGWMetaSyncEnv *env, int num_shards,
map<uint32_t, rgw_meta_sync_marker>& markers)
};
class RGWShardCollectCR : public RGWCoroutine {
- int cur_shard = 0;
- int current_running;
+ int current_running = 0;
+ protected:
int max_concurrent;
- int status;
-
-public:
- RGWShardCollectCR(CephContext *_cct, int _max_concurrent) : RGWCoroutine(_cct),
- current_running(0),
- max_concurrent(_max_concurrent),
- status(0) {}
+ int status = 0;
+
+ // called with the result of each child. error codes can be ignored by
+ // returning 0. if handle_result() returns a negative value, it's
+ // treated as an error and stored in 'status'. the last such error is
+ // reported to the caller with set_cr_error()
+ virtual int handle_result(int r) = 0;
+ public:
+ RGWShardCollectCR(CephContext *_cct, int _max_concurrent)
+ : RGWCoroutine(_cct), max_concurrent(_max_concurrent)
+ {}
virtual bool spawn_next() = 0;
int operate(const DoutPrefixProvider *dpp) override;
const RGWBucketInfo& bucket_info;
const std::vector<std::string>& markers; //< shard markers to trim
size_t i{0}; //< index of current shard marker
+
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to trim bilog shard: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
BucketTrimShardCollectCR(const DoutPrefixProvider *dpp,
rgw::sal::RadosStore* store, const RGWBucketInfo& bucket_info,
std::vector<std::string>::const_iterator bucket;
std::vector<std::string>::const_iterator end;
const DoutPrefixProvider *dpp;
+
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to trim bucket instance: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
BucketTrimInstanceCollectCR(rgw::sal::RadosStore* store, RGWHTTPManager *http,
BucketTrimObserver *observer,
static constexpr int max_concurrent = 16;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to remove mdlog shard: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
PurgeLogShardsCR(rgw::sal::RadosStore* store, const RGWMetadataLog* mdlog,
const rgw_pool& pool, int num_shards)
std::string oid;
const rgw_meta_sync_status& sync_status;
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to trim mdlog shard: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
MetaMasterTrimShardCollectCR(MasterTrimEnv& env, RGWMetadataLog *mdlog,
const rgw_meta_sync_status& sync_status)
MasterTrimEnv& env;
connection_map::iterator c;
std::vector<rgw_meta_sync_status>::iterator s;
+
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to fetch metadata sync status: "
+ << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
explicit MetaMasterStatusCollectCR(MasterTrimEnv& env)
: RGWShardCollectCR(env.store->ctx(), MAX_CONCURRENT_SHARDS),
RGWMetaSyncEnv meta_env; //< for RGWListRemoteMDLogShardCR
int shard_id{0};
+ int handle_result(int r) override {
+ if (r == -ENOENT) { // ENOENT is not a fatal error
+ return 0;
+ }
+ if (r < 0) {
+ ldout(cct, 4) << "failed to trim mdlog shard: " << cpp_strerror(r) << dendl;
+ }
+ return r;
+ }
public:
MetaPeerTrimShardCollectCR(PeerTrimEnv& env, RGWMetadataLog *mdlog)
: RGWShardCollectCR(env.store->ctx(), MAX_CONCURRENT_SHARDS),