|
|
545b23 |
From 1560268428ba1e0137b65012c9e740dbc6e7bc8f Mon Sep 17 00:00:00 2001
|
|
|
545b23 |
From: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
Date: Wed, 8 Apr 2015 20:18:50 -0400
|
|
|
545b23 |
Subject: [PATCH 16/22] librbd: add new fail method to AioCompletion
|
|
|
545b23 |
|
|
|
545b23 |
Helper method to handle passing fatal errors generated within
|
|
|
545b23 |
librbd (not from the OSDs) back to the client.
|
|
|
545b23 |
|
|
|
545b23 |
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
|
|
|
545b23 |
(cherry picked from commit 6d1d0c867855a96bee4c13a0c0a39a0e002ccd12)
|
|
|
545b23 |
(cherry picked from commit a8a1d2c947bf7b345c49864e8bd569bdcf39da72)
|
|
|
545b23 |
|
|
|
545b23 |
Conflicts:
|
|
|
545b23 |
src/librbd/AioCompletion.cc: removed refs to pending AIO
|
|
|
545b23 |
src/librbd/AioCompletion.h: removed refs to pending AIO
|
|
|
545b23 |
---
|
|
|
545b23 |
src/librbd/AioCompletion.cc | 41 +++++++++++++++++++++++++++++++++++++++--
|
|
|
545b23 |
src/librbd/AioCompletion.h | 25 ++-----------------------
|
|
|
545b23 |
2 files changed, 41 insertions(+), 25 deletions(-)
|
|
|
545b23 |
|
|
|
545b23 |
diff --git a/src/librbd/AioCompletion.cc b/src/librbd/AioCompletion.cc
|
|
|
545b23 |
index 86b5b50..531f151 100644
|
|
|
545b23 |
--- a/src/librbd/AioCompletion.cc
|
|
|
545b23 |
+++ b/src/librbd/AioCompletion.cc
|
|
|
545b23 |
@@ -5,6 +5,7 @@
|
|
|
545b23 |
|
|
|
545b23 |
#include "common/ceph_context.h"
|
|
|
545b23 |
#include "common/dout.h"
|
|
|
545b23 |
+#include "common/errno.h"
|
|
|
545b23 |
|
|
|
545b23 |
#include "librbd/AioRequest.h"
|
|
|
545b23 |
#include "librbd/internal.h"
|
|
|
545b23 |
@@ -25,7 +26,7 @@ namespace librbd {
|
|
|
545b23 |
building = false;
|
|
|
545b23 |
if (!pending_count) {
|
|
|
545b23 |
finalize(cct, rval);
|
|
|
545b23 |
- complete();
|
|
|
545b23 |
+ complete(cct);
|
|
|
545b23 |
}
|
|
|
545b23 |
lock.Unlock();
|
|
|
545b23 |
}
|
|
|
545b23 |
@@ -54,6 +55,42 @@ namespace librbd {
|
|
|
545b23 |
}
|
|
|
545b23 |
}
|
|
|
545b23 |
|
|
|
545b23 |
+ void AioCompletion::complete(CephContext *cct) {
|
|
|
545b23 |
+ utime_t elapsed;
|
|
|
545b23 |
+ assert(lock.is_locked());
|
|
|
545b23 |
+ elapsed = ceph_clock_now(cct) - start_time;
|
|
|
545b23 |
+ switch (aio_type) {
|
|
|
545b23 |
+ case AIO_TYPE_READ:
|
|
|
545b23 |
+ ictx->perfcounter->tinc(l_librbd_aio_rd_latency, elapsed); break;
|
|
|
545b23 |
+ case AIO_TYPE_WRITE:
|
|
|
545b23 |
+ ictx->perfcounter->tinc(l_librbd_aio_wr_latency, elapsed); break;
|
|
|
545b23 |
+ case AIO_TYPE_DISCARD:
|
|
|
545b23 |
+ ictx->perfcounter->tinc(l_librbd_aio_discard_latency, elapsed); break;
|
|
|
545b23 |
+ case AIO_TYPE_FLUSH:
|
|
|
545b23 |
+ ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
|
|
|
545b23 |
+ default:
|
|
|
545b23 |
+ lderr(cct) << "completed invalid aio_type: " << aio_type << dendl;
|
|
|
545b23 |
+ break;
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+
|
|
|
545b23 |
+ if (complete_cb) {
|
|
|
545b23 |
+ complete_cb(rbd_comp, complete_arg);
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+ done = true;
|
|
|
545b23 |
+ cond.Signal();
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+
|
|
|
545b23 |
+ void AioCompletion::fail(CephContext *cct, int r)
|
|
|
545b23 |
+ {
|
|
|
545b23 |
+ lderr(cct) << "AioCompletion::fail() " << this << ": " << cpp_strerror(r)
|
|
|
545b23 |
+ << dendl;
|
|
|
545b23 |
+ lock.Lock();
|
|
|
545b23 |
+ assert(pending_count == 0);
|
|
|
545b23 |
+ rval = r;
|
|
|
545b23 |
+ complete(cct);
|
|
|
545b23 |
+ put_unlock();
|
|
|
545b23 |
+ }
|
|
|
545b23 |
+
|
|
|
545b23 |
void AioCompletion::complete_request(CephContext *cct, ssize_t r)
|
|
|
545b23 |
{
|
|
|
545b23 |
ldout(cct, 20) << "AioCompletion::complete_request() "
|
|
|
545b23 |
@@ -70,7 +107,7 @@ namespace librbd {
|
|
|
545b23 |
int count = --pending_count;
|
|
|
545b23 |
if (!count && !building) {
|
|
|
545b23 |
finalize(cct, rval);
|
|
|
545b23 |
- complete();
|
|
|
545b23 |
+ complete(cct);
|
|
|
545b23 |
}
|
|
|
545b23 |
put_unlock();
|
|
|
545b23 |
}
|
|
|
545b23 |
diff --git a/src/librbd/AioCompletion.h b/src/librbd/AioCompletion.h
|
|
|
545b23 |
index aaccefe..82d3442 100644
|
|
|
545b23 |
--- a/src/librbd/AioCompletion.h
|
|
|
545b23 |
+++ b/src/librbd/AioCompletion.h
|
|
|
545b23 |
@@ -97,29 +97,8 @@ namespace librbd {
|
|
|
545b23 |
start_time = ceph_clock_now(ictx->cct);
|
|
|
545b23 |
}
|
|
|
545b23 |
|
|
|
545b23 |
- void complete() {
|
|
|
545b23 |
- utime_t elapsed;
|
|
|
545b23 |
- assert(lock.is_locked());
|
|
|
545b23 |
- elapsed = ceph_clock_now(ictx->cct) - start_time;
|
|
|
545b23 |
- switch (aio_type) {
|
|
|
545b23 |
- case AIO_TYPE_READ:
|
|
|
545b23 |
- ictx->perfcounter->tinc(l_librbd_aio_rd_latency, elapsed); break;
|
|
|
545b23 |
- case AIO_TYPE_WRITE:
|
|
|
545b23 |
- ictx->perfcounter->tinc(l_librbd_aio_wr_latency, elapsed); break;
|
|
|
545b23 |
- case AIO_TYPE_DISCARD:
|
|
|
545b23 |
- ictx->perfcounter->tinc(l_librbd_aio_discard_latency, elapsed); break;
|
|
|
545b23 |
- case AIO_TYPE_FLUSH:
|
|
|
545b23 |
- ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
|
|
|
545b23 |
- default:
|
|
|
545b23 |
- lderr(ictx->cct) << "completed invalid aio_type: " << aio_type << dendl;
|
|
|
545b23 |
- break;
|
|
|
545b23 |
- }
|
|
|
545b23 |
- if (complete_cb) {
|
|
|
545b23 |
- complete_cb(rbd_comp, complete_arg);
|
|
|
545b23 |
- }
|
|
|
545b23 |
- done = true;
|
|
|
545b23 |
- cond.Signal();
|
|
|
545b23 |
- }
|
|
|
545b23 |
+ void complete(CephContext *cct);
|
|
|
545b23 |
+ void fail(CephContext *cct, int r);
|
|
|
545b23 |
|
|
|
545b23 |
void set_complete_cb(void *cb_arg, callback_t cb) {
|
|
|
545b23 |
complete_cb = cb;
|
|
|
545b23 |
--
|
|
|
545b23 |
2.1.0
|
|
|
545b23 |
|