#include "common/ceph_context.h"
#include "common/dout.h"
+#include "common/errno.h"
#include "librbd/AioRequest.h"
#include "librbd/internal.h"
}
}
- 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;
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);
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() "
int count = --pending_count;
if (!count && blockers == 0) {
finalize(cct, rval);
- complete();
+ complete(cct);
}
put_unlock();
}