]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: complete with -ECANCELED queued task requests instead of deleting 37880/head
authorMykola Golub <mgolub@suse.com>
Wed, 28 Oct 2020 13:36:09 +0000 (13:36 +0000)
committerMykola Golub <mgolub@suse.com>
Wed, 28 Oct 2020 13:43:43 +0000 (13:43 +0000)
This is cleanup just to make it consistent with other cases.

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/ImageWatcher.cc
src/librbd/TaskFinisher.h

index 44e748fb974be6b939a267e6ccfaeb70bffb3bca..13ab9d4541ea56ac5331ed51649a51ee45904978 100644 (file)
@@ -112,9 +112,11 @@ void ImageWatcher<I>::block_notifies(Context *on_finish) {
 template <typename I>
 void ImageWatcher<I>::schedule_async_progress(const AsyncRequestId &request,
                                              uint64_t offset, uint64_t total) {
-  auto ctx = new LambdaContext(
-    boost::bind(&ImageWatcher<I>::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 <typename I>
 void ImageWatcher<I>::schedule_async_complete(const AsyncRequestId &request,
                                               int r) {
   m_async_op_tracker.start_op();
-  auto ctx = new LambdaContext(
-    boost::bind(&ImageWatcher<I>::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<I>::notify_metadata_remove(const std::string &key,
 
 template <typename I>
 void ImageWatcher<I>::schedule_cancel_async_requests() {
-  auto ctx = new LambdaContext(
-    boost::bind(&ImageWatcher<I>::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);
 }
 
index 97f6e529f6ee61a047724cddf2ce5ecc26f1476c..65e7da4a6bae5e82795c2e6c67c3c6cd8eaecb92 100644 (file)
@@ -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;
       }
     }