From 5c3ba95b4d1208868db1d00d1ba06ed086e1b268 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Tue, 29 Sep 2020 10:07:56 +0100 Subject: [PATCH] librbd: reset complete async request expiration time Signed-off-by: Mykola Golub --- src/librbd/ImageWatcher.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index db854511ee7da..15240a6f109d6 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -615,11 +615,18 @@ bool ImageWatcher::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::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::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::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)); -- 2.39.5