]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: track complete async operation return code
authorMykola Golub <mgolub@suse.com>
Mon, 21 Sep 2020 13:32:17 +0000 (14:32 +0100)
committerMykola Golub <mgolub@suse.com>
Mon, 21 Sep 2020 13:39:46 +0000 (14:39 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/ImageWatcher.cc
src/librbd/ImageWatcher.h

index 575a5fe3229a1cf2edf0a22290624d2536e48d06..06d775307a19865fdebddad0b339ccb40751a632 100644 (file)
@@ -167,7 +167,7 @@ void ImageWatcher<I>::handle_async_complete(const AsyncRequestId &request,
   }
 
   std::unique_lock async_request_locker{m_async_request_lock};
-  mark_async_request_complete(request);
+  mark_async_request_complete(request, r);
   m_async_op_tracker.finish_op();
 }
 
@@ -601,7 +601,8 @@ bool ImageWatcher<I>::is_new_request(const AsyncRequestId &id) const {
 }
 
 template <typename I>
-bool ImageWatcher<I>::mark_async_request_complete(const AsyncRequestId &id) {
+bool ImageWatcher<I>::mark_async_request_complete(const AsyncRequestId &id,
+                                                  int r) {
   ceph_assert(ceph_mutex_is_locked(m_async_request_lock));
 
   bool found = m_async_pending.erase(id);
@@ -614,7 +615,7 @@ bool ImageWatcher<I>::mark_async_request_complete(const AsyncRequestId &id) {
     it = m_async_complete_expiration.erase(it);
   }
 
-  if (m_async_complete.insert(id).second) {
+  if (m_async_complete.insert({id, r}).second) {
     auto expiration_time = now;
     expiration_time += 600;
     m_async_complete_expiration.insert({expiration_time, id});
@@ -710,6 +711,10 @@ int ImageWatcher<I>::prepare_async_request(const AsyncRequestId& async_request_i
       *ctx = new RemoteContext(*this, async_request_id, *prog_ctx);
     } else {
       *new_request = false;
+      auto it = m_async_complete.find(async_request_id);
+      if (it != m_async_complete.end()) {
+        return it->second;
+      }
     }
   }
   return 0;
@@ -728,7 +733,12 @@ Context *ImageWatcher<I>::prepare_quiesce_request(
       delete it->second.first;
       it->second.first = ack_ctx;
     } else {
-      m_task_finisher->queue(new C_ResponseMessage(ack_ctx));
+      int r = 0;
+      auto it = m_async_complete.find(request);
+      if (it != m_async_complete.end()) {
+        r = it->second;
+      }
+      m_task_finisher->queue(new C_ResponseMessage(ack_ctx), r);
     }
     locker.unlock();
 
@@ -744,16 +754,16 @@ Context *ImageWatcher<I>::prepare_quiesce_request(
   return new LambdaContext(
     [this, request, timeout](int r) {
       auto unquiesce_ctx = new LambdaContext(
-        [this, request](int r) {
+        [this, request, ret_val=r](int r) {
           if (r == 0) {
             ldout(m_image_ctx.cct, 10) << this << " quiesce request "
                                        << request << " timed out" << dendl;
           }
 
           auto on_finish = new LambdaContext(
-            [this, request](int r) {
+            [this, request, ret_val](int r) {
               std::unique_lock async_request_locker{m_async_request_lock};
-              mark_async_request_complete(request);
+              mark_async_request_complete(request, ret_val);
             });
 
           m_image_ctx.state->notify_unquiesce(on_finish);
@@ -774,7 +784,7 @@ template <typename I>
 Context *ImageWatcher<I>::prepare_unquiesce_request(const AsyncRequestId &request) {
   {
     std::unique_lock async_request_locker{m_async_request_lock};
-    bool found = mark_async_request_complete(request);
+    bool found = mark_async_request_complete(request, 0);
     if (!found) {
       ldout(m_image_ctx.cct, 20) << this << " " << request
                                  << ": not found in pending" << dendl;
index ac0232d891ea5bf8d326e401d3fb79e6d099e43a..cd7995bc070e7cdd4541820f05bd1a0a7d44e9e7 100644 (file)
@@ -169,7 +169,7 @@ private:
   ceph::shared_mutex m_async_request_lock;
   std::map<watch_notify::AsyncRequestId, AsyncRequest> m_async_requests;
   std::set<watch_notify::AsyncRequestId> m_async_pending;
-  std::set<watch_notify::AsyncRequestId> m_async_complete;
+  std::map<watch_notify::AsyncRequestId, int> m_async_complete;
   std::set<std::pair<utime_t,
                      watch_notify::AsyncRequestId>> m_async_complete_expiration;
 
@@ -192,7 +192,8 @@ private:
   void notify_lock_owner(watch_notify::Payload *payload, Context *on_finish);
 
   bool is_new_request(const watch_notify::AsyncRequestId &id) const;
-  bool mark_async_request_complete(const watch_notify::AsyncRequestId &id);
+  bool mark_async_request_complete(const watch_notify::AsyncRequestId &id,
+                                   int r);
   Context *remove_async_request(const watch_notify::AsyncRequestId &id);
   void schedule_async_request_timed_out(const watch_notify::AsyncRequestId &id);
   void async_request_timed_out(const watch_notify::AsyncRequestId &id);