]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: more backoff related changes and fixes
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 11 Nov 2015 23:01:36 +0000 (15:01 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:31 +0000 (16:13 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_data_sync.cc
src/rgw/rgw_sync.cc
src/rgw/rgw_sync.h

index 523a4e5cc407fd27f58a5cb55a8713ef91a155ab..c8a613849c367c78dd8ea03bdd7a30770ec68123 100644 (file)
@@ -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)
index fd1754a41e190c57e454c1356abcf615f743da1d..38fbcf9abf0ecd801075b9f0682d189166144527 100644 (file)
@@ -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<rgw_meta_sync_marker>(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<rgw_meta_sync_marker>(sync_env->async_rados, store, obj_ctx, store->get_zone_params().log_pool,
+                                                               sync_env->shard_obj_name(shard_id), &sync_marker);
   }
 };
 
index 4804da547fc90421d725cb2e24196581b51a3b4e..f308fbeaad9da60ada6cb7253fe8ddfb2c5ac159 100644 (file)
@@ -73,6 +73,7 @@ public:
   }
 
   virtual RGWCoroutine *alloc_cr() = 0;
+  virtual RGWCoroutine *alloc_finisher_cr() { return NULL; }
 
   int operate();
 };