]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use RGWShardCollectCR for RGWReadSyncStatusCoroutine
authorCasey Bodley <cbodley@redhat.com>
Mon, 1 Aug 2016 19:21:52 +0000 (15:21 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 6 Jun 2017 23:16:35 +0000 (19:16 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a4bf014b8642073f3eac226a93f6360cdd9cee25)

Conflicts:
src/rgw/rgw_sync.cc: rgw_pool, rgw_raw_obj

src/rgw/rgw_sync.cc

index 8ab0dd4f3d7db5f63f4c780cfad4790d9c1882e5..4d40e90c297ced127033610eb600fecf23ce81ff 100644 (file)
@@ -688,36 +688,75 @@ public:
   }
 };
 
-class RGWReadSyncStatusCoroutine : public RGWSimpleRadosReadCR<rgw_meta_sync_info> {
-  RGWMetaSyncEnv *sync_env;
+class RGWReadSyncStatusMarkersCR : public RGWShardCollectCR {
+  static constexpr int MAX_CONCURRENT_SHARDS = 16;
 
-  rgw_meta_sync_status *sync_status;
+  RGWMetaSyncEnv *env;
+  const int num_shards;
+  int shard_id{0};
+  map<uint32_t, rgw_meta_sync_marker>& markers;
 
-public:
-  RGWReadSyncStatusCoroutine(RGWMetaSyncEnv *_sync_env,
-                     rgw_meta_sync_status *_status) : RGWSimpleRadosReadCR(_sync_env->async_rados, _sync_env->store,
-                                                                           _sync_env->store->get_zone_params().log_pool,
-                                                                           _sync_env->status_oid(),
-                                                                           &_status->sync_info),
-                                                                            sync_env(_sync_env),
-                                                                           sync_status(_status) {
+ public:
+  RGWReadSyncStatusMarkersCR(RGWMetaSyncEnv *env, int num_shards,
+                             map<uint32_t, rgw_meta_sync_marker>& markers)
+    : RGWShardCollectCR(env->cct, MAX_CONCURRENT_SHARDS),
+      env(env), num_shards(num_shards), markers(markers)
+  {}
+  bool spawn_next() override;
+};
 
+bool RGWReadSyncStatusMarkersCR::spawn_next()
+{
+  if (shard_id >= num_shards) {
+    return false;
   }
+  using CR = RGWSimpleRadosReadCR<rgw_meta_sync_marker>;
+  const auto& pool = env->store->get_zone_params().log_pool;
+  const auto& oid = env->shard_obj_name(shard_id);
+  spawn(new CR(env->async_rados, env->store, pool, oid, &markers[shard_id]), false);
+  shard_id++;
+  return true;
+}
+
+class RGWReadSyncStatusCoroutine : public RGWCoroutine {
+  RGWMetaSyncEnv *sync_env;
+  rgw_meta_sync_status *sync_status;
 
-  int handle_data(rgw_meta_sync_info& data);
+public:
+  RGWReadSyncStatusCoroutine(RGWMetaSyncEnv *_sync_env,
+                             rgw_meta_sync_status *_status)
+    : RGWCoroutine(_sync_env->cct), sync_env(_sync_env), sync_status(_status)
+  {}
+  int operate() override;
 };
 
-int RGWReadSyncStatusCoroutine::handle_data(rgw_meta_sync_info& data)
+int RGWReadSyncStatusCoroutine::operate()
 {
-  if (retcode == -ENOENT) {
-    return 0;
-  }
-
-  RGWRados *store = sync_env->store;
-  map<uint32_t, rgw_meta_sync_marker>& markers = sync_status->sync_markers;
-  for (int i = 0; i < (int)data.num_shards; i++) {
-    spawn(new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
-                                                   sync_env->shard_obj_name(i), &markers[i]), true);
+  reenter(this) {
+    // read sync info
+    using ReadInfoCR = RGWSimpleRadosReadCR<rgw_meta_sync_info>;
+    yield {
+      bool empty_on_enoent = false; // fail on ENOENT
+      const auto& pool = sync_env->store->get_zone_params().log_pool;
+      const auto& oid = sync_env->status_oid();
+      call(new ReadInfoCR(sync_env->async_rados, sync_env->store, pool, oid,
+                          &sync_status->sync_info, empty_on_enoent));
+    }
+    if (retcode < 0) {
+      ldout(sync_env->cct, 4) << "failed to read sync status info with "
+          << cpp_strerror(retcode) << dendl;
+      return set_cr_error(retcode);
+    }
+    // read shard markers
+    using ReadMarkersCR = RGWReadSyncStatusMarkersCR;
+    yield call(new ReadMarkersCR(sync_env, sync_status->sync_info.num_shards,
+                                 sync_status->sync_markers));
+    if (retcode < 0) {
+      ldout(sync_env->cct, 4) << "failed to read sync status markers with "
+          << cpp_strerror(retcode) << dendl;
+      return set_cr_error(retcode);
+    }
+    return set_cr_done();
   }
   return 0;
 }