MCPcopy Create free account
hub / github.com/ceph/ceph / _aio_thread

Method _aio_thread

src/blk/kernel/KernelDevice.cc:673–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

671}
672
673void 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 }

Callers 1

entryMethod · 0.80

Calls 14

cpp_strerrorFunction · 0.85
is_expected_ioerrFunction · 0.85
note_io_error_eventFunction · 0.85
ceph_clock_nowFunction · 0.85
set_return_valueMethod · 0.80
try_aio_wakeMethod · 0.80
utime_tClass · 0.50
get_next_completedMethod · 0.45
is_linkedMethod · 0.45
storeMethod · 0.45
get_return_valueMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected