]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: reset complete async request expiration time 37316/head
authorMykola Golub <mgolub@suse.com>
Tue, 29 Sep 2020 09:07:56 +0000 (10:07 +0100)
committerMykola Golub <mgolub@suse.com>
Wed, 30 Sep 2020 17:51:38 +0000 (18:51 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/ImageWatcher.cc

index db854511ee7da3ebb8b50cd05a0c63f833718be3..15240a6f109d6fce50378c9c0d0144c7d4d92882 100644 (file)
@@ -615,11 +615,18 @@ bool ImageWatcher<I>::mark_async_request_complete(const AsyncRequestId &id,
     it = m_async_complete_expiration.erase(it);
   }
 
-  if (m_async_complete.insert({id, r}).second) {
-    auto expiration_time = now;
-    expiration_time += 600;
-    m_async_complete_expiration.insert({expiration_time, id});
+  if (!m_async_complete.insert({id, r}).second) {
+    for (it = m_async_complete_expiration.begin();
+         it != m_async_complete_expiration.end(); it++) {
+      if (it->second == id) {
+        m_async_complete_expiration.erase(it);
+        break;
+      }
+    }
   }
+  auto expiration_time = now;
+  expiration_time += 600;
+  m_async_complete_expiration.insert({expiration_time, id});
 
   return found;
 }
@@ -722,7 +729,10 @@ int ImageWatcher<I>::prepare_async_request(const AsyncRequestId& async_request_i
       *new_request = false;
       auto it = m_async_complete.find(async_request_id);
       if (it != m_async_complete.end()) {
-        return it->second;
+        int r = it->second;
+        // reset complete request expiration time
+        mark_async_request_complete(async_request_id, r);
+        return r;
       }
     }
   }
@@ -745,6 +755,8 @@ Context *ImageWatcher<I>::prepare_quiesce_request(
       auto it = m_async_complete.find(request);
       ceph_assert(it != m_async_complete.end());
       m_task_finisher->queue(new C_ResponseMessage(ack_ctx), it->second);
+      // reset complete request expiration time
+      mark_async_request_complete(request, it->second);
     }
     locker.unlock();
 
@@ -797,6 +809,8 @@ Context *ImageWatcher<I>::prepare_unquiesce_request(const AsyncRequestId &reques
                                  << ": not found in complete" << dendl;
       return nullptr;
     }
+    // reset complete request expiration time
+    mark_async_request_complete(request, it->second);
   }
 
   bool canceled = m_task_finisher->cancel(Task(TASK_CODE_QUIESCE, request));