From: Mykola Golub Date: Wed, 28 Oct 2020 13:36:09 +0000 (+0000) Subject: librbd: complete with -ECANCELED queued task requests instead of deleting X-Git-Tag: v16.1.0~730^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0fe9cdefdcc3c38ded49c70842468a953ede53d0;p=ceph.git librbd: complete with -ECANCELED queued task requests instead of deleting This is cleanup just to make it consistent with other cases. Signed-off-by: Mykola Golub --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 44e748fb974b..13ab9d4541ea 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -112,9 +112,11 @@ void ImageWatcher::block_notifies(Context *on_finish) { template void ImageWatcher::schedule_async_progress(const AsyncRequestId &request, uint64_t offset, uint64_t total) { - auto ctx = new LambdaContext( - boost::bind(&ImageWatcher::notify_async_progress, this, request, offset, - total)); + auto ctx = new LambdaContext([this, request, offset, total](int r) { + if (r != -ECANCELED) { + notify_async_progress(request, offset, total); + } + }); m_task_finisher->queue(Task(TASK_CODE_ASYNC_PROGRESS, request), ctx); } @@ -133,8 +135,11 @@ template void ImageWatcher::schedule_async_complete(const AsyncRequestId &request, int r) { m_async_op_tracker.start_op(); - auto ctx = new LambdaContext( - boost::bind(&ImageWatcher::notify_async_complete, this, request, r)); + auto ctx = new LambdaContext([this, request, ret_val=r](int r) { + if (r != -ECANCELED) { + notify_async_complete(request, ret_val); + } + }); m_task_finisher->queue(ctx); } @@ -463,8 +468,11 @@ void ImageWatcher::notify_metadata_remove(const std::string &key, template void ImageWatcher::schedule_cancel_async_requests() { - auto ctx = new LambdaContext( - boost::bind(&ImageWatcher::cancel_async_requests, this)); + auto ctx = new LambdaContext([this](int r) { + if (r != -ECANCELED) { + cancel_async_requests(); + } + }); m_task_finisher->queue(TASK_CODE_CANCEL_ASYNC_REQUESTS, ctx); } diff --git a/src/librbd/TaskFinisher.h b/src/librbd/TaskFinisher.h index 97f6e529f6ee..65e7da4a6bae 100644 --- a/src/librbd/TaskFinisher.h +++ b/src/librbd/TaskFinisher.h @@ -119,10 +119,10 @@ public: if (it != m_task_contexts.end()) { if (it->second.second != NULL && m_safe_timer->cancel_event(it->second.second)) { - delete it->second.first; + it->second.first->complete(-ECANCELED); } else { // task already scheduled on the finisher - delete ctx; + ctx->complete(-ECANCELED); return false; } }