]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: add new fail method to AioCompletion
authorJason Dillaman <dillaman@redhat.com>
Thu, 9 Apr 2015 00:18:50 +0000 (20:18 -0400)
committerKen Dreyer <kdreyer@redhat.com>
Wed, 24 Jun 2015 16:41:21 +0000 (10:41 -0600)
Helper method to handle passing fatal errors generated within
librbd (not from the OSDs) back to the client.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 6d1d0c867855a96bee4c13a0c0a39a0e002ccd12)
(cherry picked from commit 7df6091a30b1b94d764240262195e971175554b3)

src/librbd/AioCompletion.cc
src/librbd/AioCompletion.h
src/librbd/AsyncOperation.h

index 8c38e1c95c4a5496fc044d8cdb15ea8f511805cf..2663e74c160853c8c6eeef0c432594f217963499 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "common/ceph_context.h"
 #include "common/dout.h"
+#include "common/errno.h"
 
 #include "librbd/AioRequest.h"
 #include "librbd/internal.h"
@@ -63,11 +64,11 @@ namespace librbd {
     }
   }
 
-  void AioCompletion::complete() {
+  void AioCompletion::complete(CephContext *cct) {
     tracepoint(librbd, aio_complete_enter, this, rval);
     utime_t elapsed;
     assert(lock.is_locked());
-    elapsed = ceph_clock_now(ictx->cct) - start_time;
+    elapsed = ceph_clock_now(cct) - start_time;
     switch (aio_type) {
     case AIO_TYPE_READ:
       ictx->perfcounter->tinc(l_librbd_aio_rd_latency, elapsed); break;
@@ -78,12 +79,14 @@ namespace librbd {
     case AIO_TYPE_FLUSH:
       ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
     default:
-      lderr(ictx->cct) << "completed invalid aio_type: " << aio_type << dendl;
+      lderr(cct) << "completed invalid aio_type: " << aio_type << dendl;
       break;
     }
 
     // note: possible for image to be closed after op marked finished
-    async_op.finish_op();
+    if (async_op.started()) {
+      async_op.finish_op();
+    }
 
     if (complete_cb) {
       complete_cb(rbd_comp, complete_arg);
@@ -93,6 +96,17 @@ namespace librbd {
     tracepoint(librbd, aio_complete_exit);
   }
 
+  void AioCompletion::fail(CephContext *cct, int r)
+  {
+    lderr(cct) << "AioCompletion::fail() " << this << ": " << cpp_strerror(r)
+               << dendl;
+    lock.Lock();
+    assert(pending_count == 0);
+    rval = r;
+    complete(cct);
+    put_unlock();
+  }
+
   void AioCompletion::complete_request(CephContext *cct, ssize_t r)
   {
     ldout(cct, 20) << "AioCompletion::complete_request() "
@@ -109,7 +123,7 @@ namespace librbd {
     int count = --pending_count;
     if (!count && blockers == 0) {
       finalize(cct, rval);
-      complete();
+      complete(cct);
     }
     put_unlock();
   }
index cef8388e6202b70eb8d28b541eb886ea34ade6b2..bd527b130d6f54605911e5b74b177680c408202d 100644 (file)
@@ -98,7 +98,9 @@ namespace librbd {
       }
     }
 
-    void complete();
+    void fail(CephContext *cct, int r);
+
+    void complete(CephContext *cct);
 
     void set_complete_cb(void *cb_arg, callback_t cb) {
       complete_cb = cb;
@@ -145,7 +147,7 @@ namespace librbd {
       --blockers;
       if (pending_count == 0 && blockers == 0) {
         finalize(cct, rval);
-        complete();
+        complete(cct);
       }
     }
   };
index 2ca2aec9e22ca7cc59a5013ca479a24d86713fdd..e6c884970424b90cd8bc73145a38044865da84a0 100644 (file)
@@ -26,6 +26,10 @@ public:
     assert(!m_xlist_item.is_on_list());
   }
 
+  inline bool started() const {
+    return m_xlist_item.is_on_list();
+  }
+
   void start_op(ImageCtx &image_ctx);
   void finish_op();