| 671 | } |
| 672 | |
| 673 | void KernelDevice::_aio_thread() |
| 674 | { |
| 675 | dout(10) << __func__ << " start" << dendl; |
| 676 | int inject_crash_count = 0; |
| 677 | while (!aio_stop) { |
| 678 | dout(40) << __func__ << " polling" << dendl; |
| 679 | int max = cct->_conf->bdev_aio_reap_max; |
| 680 | aio_t *aio[max]; |
| 681 | int r = io_queue->get_next_completed(cct->_conf->bdev_aio_poll_ms, |
| 682 | aio, max); |
| 683 | if (r < 0) { |
| 684 | derr << __func__ << " got " << cpp_strerror(r) << dendl; |
| 685 | ceph_abort_msg("got unexpected error from io_getevents"); |
| 686 | } |
| 687 | if (r > 0) { |
| 688 | dout(30) << __func__ << " got " << r << " completed aios" << dendl; |
| 689 | for (int i = 0; i < r; ++i) { |
| 690 | IOContext *ioc = static_cast<IOContext*>(aio[i]->priv); |
| 691 | _aio_log_finish(ioc, aio[i]->offset, aio[i]->length); |
| 692 | if (aio[i]->queue_item.is_linked()) { |
| 693 | std::lock_guard l(debug_queue_lock); |
| 694 | debug_aio_unlink(*aio[i]); |
| 695 | } |
| 696 | |
| 697 | // set flag indicating new ios have completed. we do this *before* |
| 698 | // any completion or notifications so that any user flush() that |
| 699 | // follows the observed io completion will include this io. Note |
| 700 | // that an earlier, racing flush() could observe and clear this |
| 701 | // flag, but that also ensures that the IO will be stable before the |
| 702 | // later flush() occurs. |
| 703 | io_since_flush.store(true); |
| 704 | |
| 705 | long r = aio[i]->get_return_value(); |
| 706 | if (r < 0) { |
| 707 | derr << __func__ << " got r=" << r << " (" << cpp_strerror(r) << ")" |
| 708 | << dendl; |
| 709 | if (ioc->allow_eio && is_expected_ioerr(r)) { |
| 710 | derr << __func__ << " translating the error to EIO for upper layer" |
| 711 | << dendl; |
| 712 | ioc->set_return_value(-EIO); |
| 713 | } else { |
| 714 | if (is_expected_ioerr(r)) { |
| 715 | note_io_error_event( |
| 716 | devname.c_str(), |
| 717 | path.c_str(), |
| 718 | r, |
| 719 | #if defined(HAVE_POSIXAIO) |
| 720 | aio[i]->aio.aiocb.aio_lio_opcode, |
| 721 | #else |
| 722 | aio[i]->iocb.aio_lio_opcode, |
| 723 | #endif |
| 724 | aio[i]->offset, |
| 725 | aio[i]->length); |
| 726 | ceph_abort_msg( |
| 727 | "Unexpected IO error. " |
| 728 | "This may suggest a hardware issue. " |
| 729 | "Please check your kernel log!"); |
| 730 | } |
no test coverage detected