]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWCloneMetaLogCoroutine uses RGWMetadataLogInfoCompletion 12949/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 5 Jan 2017 18:10:50 +0000 (13:10 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 16 Jan 2017 18:54:28 +0000 (13:54 -0500)
Fixes: http://tracker.ceph.com/issues/18412
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 34a2edbf53f26a21e3206027dc61efc70d9c6aad)

src/rgw/rgw_sync.cc

index 590b3f9eb39e006a7f079aab00fef9dfdca06f11..c47dd4b7997199217d266495026d8a1308a39259 100644 (file)
@@ -1198,8 +1198,8 @@ class RGWCloneMetaLogCoroutine : public RGWCoroutine {
   int max_entries = CLONE_MAX_ENTRIES;
 
   RGWRESTReadResource *http_op = nullptr;
+  boost::intrusive_ptr<RGWMetadataLogInfoCompletion> completion;
 
-  int req_ret = 0;
   RGWMetadataLogInfo shard_info;
   rgw_mdlog_shard_data data;
 
@@ -1217,6 +1217,9 @@ public:
     if (http_op) {
       http_op->put();
     }
+    if (completion) {
+      completion->cancel();
+    }
   }
 
   int operate();
@@ -2062,7 +2065,22 @@ int RGWCloneMetaLogCoroutine::state_init()
 
 int RGWCloneMetaLogCoroutine::state_read_shard_status()
 {
-  int ret = mdlog->get_info_async(shard_id, &shard_info, stack->get_completion_mgr(), (void *)stack, &req_ret);
+  const bool add_ref = false; // default constructs with refs=1
+
+  completion.reset(new RGWMetadataLogInfoCompletion(
+    [this](int ret, const cls_log_header& header) {
+      if (ret < 0) {
+        ldout(cct, 1) << "ERROR: failed to read mdlog info with "
+            << cpp_strerror(ret) << dendl;
+      } else {
+        shard_info.marker = header.max_marker;
+        shard_info.last_update = header.max_time.to_real_time();
+      }
+      // wake up parent stack
+      stack->get_completion_mgr()->complete(nullptr, stack);
+    }), add_ref);
+
+  int ret = mdlog->get_info_async(shard_id, completion.get());
   if (ret < 0) {
     ldout(cct, 0) << "ERROR: mdlog->get_info_async() returned ret=" << ret << dendl;
     return set_cr_error(ret);
@@ -2073,6 +2091,8 @@ int RGWCloneMetaLogCoroutine::state_read_shard_status()
 
 int RGWCloneMetaLogCoroutine::state_read_shard_status_complete()
 {
+  completion.reset();
+
   ldout(cct, 20) << "shard_id=" << shard_id << " marker=" << shard_info.marker << " last_update=" << shard_info.last_update << dendl;
 
   marker = shard_info.marker;