From: Yehuda Sadeh Date: Wed, 11 Nov 2015 23:01:36 +0000 (-0800) Subject: rgw: more backoff related changes and fixes X-Git-Tag: v10.1.0~354^2~219 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=35ffcff1dacb284037aa2bc8fbdb174a2a8fc671;p=ceph.git rgw: more backoff related changes and fixes Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 523a4e5cc407..c8a613849c36 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -454,7 +454,11 @@ int RGWRemoteDataLog::get_shard_info(int shard_id) int RGWRemoteDataLog::read_sync_status(rgw_data_sync_status *sync_status) { RGWObjectCtx obj_ctx(store, NULL); - return run(new RGWReadDataSyncStatusCoroutine(async_rados, store, obj_ctx, source_zone, sync_status)); + int r = run(new RGWReadDataSyncStatusCoroutine(async_rados, store, obj_ctx, source_zone, sync_status)); + if (r == -ENOENT) { + r = 0; + } + return r; } int RGWRemoteDataLog::init_sync_status(int num_shards) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index fd1754a41e19..38fbcf9abf0e 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -48,11 +48,13 @@ void RGWSyncBackoff::backoff(RGWCoroutine *op) } int RGWBackoffControlCR::operate() { + RGWCoroutine *finisher_cr; reenter(this) { while (true) { yield { Mutex::Locker l(lock); cr = alloc_cr(); + cr->get(); int r = call(cr); if (r < 0) { cr->put(); @@ -74,6 +76,20 @@ int RGWBackoffControlCR::operate() { backoff.reset(); } yield backoff.backoff(this); + finisher_cr = alloc_finisher_cr(); + if (finisher_cr) { + yield { + int r = call(finisher_cr); + if (r < 0) { + ldout(cct, 0) << "ERROR: failed to call to finisher_cr(): r=" << r << dendl; + return set_cr_error(r); + } + } + if (retcode < 0) { + ldout(cct, 0) << "ERROR: call to finisher_cr() failed: retcode=" << retcode << dendl; + return set_cr_error(retcode); + } + } } } return 0; @@ -1395,7 +1411,7 @@ public: } }; -class RGWMetaSyncShardControlCR : public RGWCoroutine +class RGWMetaSyncShardControlCR : public RGWBackoffControlCR { RGWMetaSyncEnv *sync_env; @@ -1406,44 +1422,23 @@ class RGWMetaSyncShardControlCR : public RGWCoroutine RGWObjectCtx obj_ctx; - RGWSyncBackoff backoff; - bool reset_backoff; - public: RGWMetaSyncShardControlCR(RGWMetaSyncEnv *_sync_env, rgw_bucket& _pool, - uint32_t _shard_id, rgw_meta_sync_marker& _marker) : RGWCoroutine(_sync_env->cct), sync_env(_sync_env), + uint32_t _shard_id, rgw_meta_sync_marker& _marker) : RGWBackoffControlCR(_sync_env->cct), sync_env(_sync_env), pool(_pool), shard_id(_shard_id), - sync_marker(_marker), obj_ctx(sync_env->store), reset_backoff(false) { + sync_marker(_marker), obj_ctx(sync_env->store) { } - int operate() { - reenter(this) { - while (true) { - yield { - call(new RGWMetaSyncShardCR(sync_env, pool, shard_id, sync_marker, &reset_backoff)); - } - if (retcode < 0 && retcode != -EBUSY && retcode != -EAGAIN) { - ldout(sync_env->cct, 0) << "ERROR: RGWMetaSyncShardCR() returned " << retcode << dendl; - return set_cr_error(retcode); - } - if (reset_backoff) { - backoff.reset(); - } - yield backoff.backoff(this); - yield { - RGWRados *store = sync_env->store; - call(new RGWSimpleRadosReadCR(sync_env->async_rados, store, obj_ctx, store->get_zone_params().log_pool, - sync_env->shard_obj_name(shard_id), &sync_marker)); - } - if (retcode < 0) { - ldout(sync_env->cct, 0) << "ERROR: failed to read sync state for metadata shard id=" << shard_id << " retcode=" << retcode << dendl; - return set_cr_error(retcode); - } - } - } - return 0; + RGWCoroutine *alloc_cr() { + return new RGWMetaSyncShardCR(sync_env, pool, shard_id, sync_marker, backoff_ptr()); + } + + RGWCoroutine *alloc_finisher_cr() { + RGWRados *store = sync_env->store; + return new RGWSimpleRadosReadCR(sync_env->async_rados, store, obj_ctx, store->get_zone_params().log_pool, + sync_env->shard_obj_name(shard_id), &sync_marker); } }; diff --git a/src/rgw/rgw_sync.h b/src/rgw/rgw_sync.h index 4804da547fc9..f308fbeaad9d 100644 --- a/src/rgw/rgw_sync.h +++ b/src/rgw/rgw_sync.h @@ -73,6 +73,7 @@ public: } virtual RGWCoroutine *alloc_cr() = 0; + virtual RGWCoroutine *alloc_finisher_cr() { return NULL; } int operate(); };