diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 44483bb..3554553 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -427,6 +427,10 @@ class AIO { os_offset_t offset, ulint len) MY_ATTRIBUTE((warn_unused_result)); + /** Wake up the handler thread that handle this local_segment + @para[in] local_segment local segment */ + void wake_up_handler_thread(ulint local_segment); + /** @return number of reserved slots */ ulint pending_io_count() const; @@ -637,6 +641,15 @@ class AIO { static ulint get_segment_no_from_slot(const AIO *array, const Slot *slot) MY_ATTRIBUTE((warn_unused_result)); + /** Calculates global segment number for local segment. + @param[in] array AIO wait array + @param[in] local_segment local segment in this array + @return segment number (which is the number used by, for example, + I/O-handler threads) */ + static ulint get_segment_no_from_local_segment(const AIO *array, + ulint local_segment) + MY_ATTRIBUTE((warn_unused_result)); + /** Wakes up a simulated AIO I/O-handler thread if it has something to do. @param[in] global_segment the number of the segment in the @@ -6453,6 +6466,39 @@ ulint AIO::get_segment_no_from_slot(const AIO *array, const Slot *slot) { return (segment); } +/** Calculates global segment number for local segment. +@param[in] array AIO wait array +@param[in] local_segment local segment in this array +@return segment number (which is the number used by, for example, + I/O-handler threads) */ +ulint AIO::get_segment_no_from_local_segment(const AIO *array, + ulint local_segment) { + ulint segment; + + if (array == s_ibuf) { + ut_ad(!srv_read_only_mode); + + segment = IO_IBUF_SEGMENT; + + } else if (array == s_log) { + ut_ad(!srv_read_only_mode); + + segment = IO_LOG_SEGMENT; + + } else if (array == s_reads) { + + segment = (srv_read_only_mode ? 0 : 2) + local_segment; + + } else { + ut_a(array == s_writes); + + segment = s_reads->m_n_segments + (srv_read_only_mode ? 0 : 2) + + local_segment; + } + + return (segment); +} + /** Requests for a slot in the aio array. If no slot is available, waits until not_full-event becomes signaled. @@ -6499,10 +6545,10 @@ Slot *AIO::reserve_slot(IORequest &type, fil_node_t *m1, void *m2, release(); if (!srv_use_native_aio) { - /* If the handler threads are suspended, - wake them so that we get more slots */ - os_aio_simulated_wake_handler_threads(); + /* If the handler thread that handle this slot is suspended, + wake up it so that we get more slots */ + wake_up_handler_thread(local_seg); } os_event_wait(m_not_full); @@ -6681,6 +6727,14 @@ Slot *AIO::reserve_slot(IORequest &type, fil_node_t *m1, void *m2, return (slot); } +/** Wake up the handler thread that handle this local_segment +@para[in] local_segment local segment */ +void AIO::wake_up_handler_thread(ulint local_segment) { + ulint global_segment = AIO::get_segment_no_from_local_segment(this, + local_segment); + AIO::wake_simulated_handler_thread(global_segment, local_segment); + +} /** Wakes up a simulated aio i/o-handler thread if it has something to do. @param[in] global_segment The number of the segment in the AIO arrays */ void AIO::wake_simulated_handler_thread(ulint global_segment) {