]> git-server-git.apps.pok.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)
committerJason Dillaman <dillaman@redhat.com>
Fri, 24 Jul 2015 13:59:56 +0000 (09:59 -0400)
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)

Conflicts:
src/librbd/AioCompletion.cc: trivial resolution
src/librbd/AioCompletion.h: trivial resolution

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

index 86b5b504ebd3d96ac679c10f6e24c978a7da1756..e818674babc2c530bfe793686a79b74dae304e97 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"
@@ -25,7 +26,7 @@ namespace librbd {
     building = false;
     if (!pending_count) {
       finalize(cct, rval);
-      complete();
+      complete(cct);
     }
     lock.Unlock();
   }
@@ -54,6 +55,49 @@ namespace librbd {
     }
   }
 
+  void AioCompletion::complete(CephContext *cct) {
+    utime_t elapsed;
+    assert(lock.is_locked());
+    elapsed = ceph_clock_now(cct) - start_time;
+    switch (aio_type) {
+    case AIO_TYPE_READ:
+      ictx->perfcounter->tinc(l_librbd_aio_rd_latency, elapsed); break;
+    case AIO_TYPE_WRITE:
+      ictx->perfcounter->tinc(l_librbd_aio_wr_latency, elapsed); break;
+    case AIO_TYPE_DISCARD:
+      ictx->perfcounter->tinc(l_librbd_aio_discard_latency, elapsed); break;
+    case AIO_TYPE_FLUSH:
+      ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
+    default:
+      lderr(cct) << "completed invalid aio_type: " << aio_type << dendl;
+      break;
+    }
+
+    if (ictx != NULL) {
+      Mutex::Locker l(ictx->aio_lock);
+      assert(ictx->pending_aio != 0);
+      --ictx->pending_aio;
+      ictx->pending_aio_cond.Signal();
+    }
+
+    if (complete_cb) {
+      complete_cb(rbd_comp, complete_arg);
+    }
+    done = true;
+    cond.Signal();
+  }
+
+  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() "
@@ -70,7 +114,7 @@ namespace librbd {
     int count = --pending_count;
     if (!count && !building) {
       finalize(cct, rval);
-      complete();
+      complete(cct);
     }
     put_unlock();
   }
index e28cd6a06054f2b70456aa332b54970da6c629b0..4dbad521a9186633631d6438f310574898a2f3ca 100644 (file)
@@ -101,37 +101,8 @@ namespace librbd {
       start_time = ceph_clock_now(ictx->cct);
     }
 
-    void complete() {
-      utime_t elapsed;
-      assert(lock.is_locked());
-      elapsed = ceph_clock_now(ictx->cct) - start_time;
-      switch (aio_type) {
-      case AIO_TYPE_READ:
-       ictx->perfcounter->tinc(l_librbd_aio_rd_latency, elapsed); break;
-      case AIO_TYPE_WRITE:
-       ictx->perfcounter->tinc(l_librbd_aio_wr_latency, elapsed); break;
-      case AIO_TYPE_DISCARD:
-       ictx->perfcounter->tinc(l_librbd_aio_discard_latency, elapsed); break;
-      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;
-       break;
-      }
-
-      {
-        Mutex::Locker l(ictx->aio_lock);
-        assert(ictx->pending_aio != 0);
-        --ictx->pending_aio;
-        ictx->pending_aio_cond.Signal();
-      }
-
-      if (complete_cb) {
-       complete_cb(rbd_comp, complete_arg);
-      }
-      done = true;
-      cond.Signal();
-    }
+    void complete(CephContext *cct);
+    void fail(CephContext *cct, int r);
 
     void set_complete_cb(void *cb_arg, callback_t cb) {
       complete_cb = cb;