]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/io/AioCompletion.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / io / AioCompletion.cc
index d58d4f35597cdecb60a0227d8533fdefc37dbf5b..661cd57255b3d9486f4fcb07c70168e9cd49408c 100644 (file)
@@ -41,8 +41,8 @@ int AioCompletion::wait_for_complete() {
 
 void AioCompletion::finalize(ssize_t rval)
 {
-  assert(lock.is_locked());
-  assert(ictx != nullptr);
+  ceph_assert(lock.is_locked());
+  ceph_assert(ictx != nullptr);
   CephContext *cct = ictx->cct;
 
   ldout(cct, 20) << "r=" << rval << dendl;
@@ -52,39 +52,34 @@ void AioCompletion::finalize(ssize_t rval)
 }
 
 void AioCompletion::complete() {
-  assert(lock.is_locked());
-  assert(ictx != nullptr);
+  ceph_assert(lock.is_locked());
+  ceph_assert(ictx != nullptr);
   CephContext *cct = ictx->cct;
 
   tracepoint(librbd, aio_complete_enter, this, rval);
-  utime_t elapsed;
-  elapsed = ceph_clock_now() - start_time;
-  switch (aio_type) {
-  case AIO_TYPE_GENERIC:
-  case AIO_TYPE_OPEN:
-  case AIO_TYPE_CLOSE:
-    break;
-  case AIO_TYPE_READ:
-    ictx->perfcounter->tinc(l_librbd_rd_latency, elapsed); break;
-  case AIO_TYPE_WRITE:
-    ictx->perfcounter->tinc(l_librbd_wr_latency, elapsed); break;
-  case AIO_TYPE_DISCARD:
-    ictx->perfcounter->tinc(l_librbd_discard_latency, elapsed); break;
-  case AIO_TYPE_FLUSH:
-    ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
-  case AIO_TYPE_WRITESAME:
-    ictx->perfcounter->tinc(l_librbd_ws_latency, elapsed); break;
-  case AIO_TYPE_COMPARE_AND_WRITE:
-    ictx->perfcounter->tinc(l_librbd_cmp_latency, elapsed); break;
-  default:
-    lderr(cct) << "completed invalid aio_type: " << aio_type << dendl;
-    break;
-  }
-
-  // inform the journal that the op has successfully committed
-  if (journal_tid != 0) {
-    assert(ictx->journal != NULL);
-    ictx->journal->commit_io_event(journal_tid, rval);
+  if (ictx->perfcounter != nullptr) {
+    ceph::timespan elapsed = coarse_mono_clock::now() - start_time;
+    switch (aio_type) {
+    case AIO_TYPE_GENERIC:
+    case AIO_TYPE_OPEN:
+    case AIO_TYPE_CLOSE:
+      break;
+    case AIO_TYPE_READ:
+      ictx->perfcounter->tinc(l_librbd_rd_latency, elapsed); break;
+    case AIO_TYPE_WRITE:
+      ictx->perfcounter->tinc(l_librbd_wr_latency, elapsed); break;
+    case AIO_TYPE_DISCARD:
+      ictx->perfcounter->tinc(l_librbd_discard_latency, elapsed); break;
+    case AIO_TYPE_FLUSH:
+      ictx->perfcounter->tinc(l_librbd_flush_latency, elapsed); break;
+    case AIO_TYPE_WRITESAME:
+      ictx->perfcounter->tinc(l_librbd_ws_latency, elapsed); break;
+    case AIO_TYPE_COMPARE_AND_WRITE:
+      ictx->perfcounter->tinc(l_librbd_cmp_latency, elapsed); break;
+    default:
+      lderr(cct) << "completed invalid aio_type: " << aio_type << dendl;
+      break;
+    }
   }
 
   state = AIO_STATE_CALLBACK;
@@ -94,7 +89,7 @@ void AioCompletion::complete() {
     lock.Lock();
   }
 
-  if (ictx && event_notify && ictx->event_socket.is_valid()) {
+  if (event_notify && ictx->event_socket.is_valid()) {
     ictx->completed_reqs_lock.Lock();
     ictx->completed_reqs.push_back(&m_xlist_item);
     ictx->completed_reqs_lock.Unlock();
@@ -116,14 +111,14 @@ void AioCompletion::init_time(ImageCtx *i, aio_type_t t) {
   if (ictx == nullptr) {
     ictx = i;
     aio_type = t;
-    start_time = ceph_clock_now();
+    start_time = coarse_mono_clock::now();
   }
 }
 
 void AioCompletion::start_op(bool ignore_type) {
   Mutex::Locker locker(lock);
-  assert(ictx != nullptr);
-  assert(!async_op.started());
+  ceph_assert(ictx != nullptr);
+  ceph_assert(!async_op.started());
   if (state == AIO_STATE_PENDING &&
       (ignore_type || aio_type != AIO_TYPE_FLUSH)) {
     async_op.start_op(*ictx);
@@ -133,11 +128,11 @@ void AioCompletion::start_op(bool ignore_type) {
 void AioCompletion::fail(int r)
 {
   lock.Lock();
-  assert(ictx != nullptr);
+  ceph_assert(ictx != nullptr);
   CephContext *cct = ictx->cct;
 
   lderr(cct) << cpp_strerror(r) << dendl;
-  assert(pending_count == 0);
+  ceph_assert(pending_count == 0);
   rval = r;
   complete();
   put_unlock();
@@ -145,11 +140,11 @@ void AioCompletion::fail(int r)
 
 void AioCompletion::set_request_count(uint32_t count) {
   lock.Lock();
-  assert(ictx != nullptr);
+  ceph_assert(ictx != nullptr);
   CephContext *cct = ictx->cct;
 
   ldout(cct, 20) << "pending=" << count << dendl;
-  assert(pending_count == 0);
+  ceph_assert(pending_count == 0);
   pending_count = count;
   lock.Unlock();
 
@@ -160,7 +155,7 @@ void AioCompletion::set_request_count(uint32_t count) {
 void AioCompletion::complete_request(ssize_t r)
 {
   lock.Lock();
-  assert(ictx != nullptr);
+  ceph_assert(ictx != nullptr);
   CephContext *cct = ictx->cct;
 
   if (rval >= 0) {
@@ -169,7 +164,7 @@ void AioCompletion::complete_request(ssize_t r)
     else if (r > 0)
       rval += r;
   }
-  assert(pending_count);
+  ceph_assert(pending_count);
   int count = --pending_count;
 
   ldout(cct, 20) << "cb=" << complete_cb << ", "
@@ -181,12 +176,6 @@ void AioCompletion::complete_request(ssize_t r)
   put_unlock();
 }
 
-void AioCompletion::associate_journal_event(uint64_t tid) {
-  Mutex::Locker l(lock);
-  assert(state == AIO_STATE_PENDING);
-  journal_tid = tid;
-}
-
 bool AioCompletion::is_complete() {
   tracepoint(librbd, aio_is_complete_enter, this);
   bool done;