summaryrefslogtreecommitdiff
path: root/storage/innobase/os/os0file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/os/os0file.cc')
-rw-r--r--storage/innobase/os/os0file.cc115
1 files changed, 61 insertions, 54 deletions
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 98bf4fdb8ca..08f525be314 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -106,9 +106,9 @@ public:
}
/* Wait for completions of all AIO operations */
- void wait(std::unique_lock<std::mutex> &lk)
+ void wait(mysql_mutex_t &m)
{
- m_cache.wait(lk);
+ m_cache.wait(m);
}
void wait()
@@ -131,14 +131,13 @@ public:
wait();
}
- std::mutex& mutex()
+ mysql_mutex_t& mutex()
{
return m_cache.mutex();
}
- void resize(int max_submitted_io, int max_callback_concurrency, std::unique_lock<std::mutex> &lk)
+ void resize(int max_submitted_io, int max_callback_concurrency)
{
- ut_a(lk.owns_lock());
m_cache.resize(max_submitted_io);
m_group.set_max_tasks(max_callback_concurrency);
m_max_aio = max_submitted_io;
@@ -751,22 +750,16 @@ os_file_punch_hole_posix(
return(DB_IO_NO_PUNCH_HOLE);
}
-
-
/** Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
the OS error number + 100 is returned.
@param[in] report_all_errors true if we want an error message
- printed of all errors
+ printed of all errors
@param[in] on_error_silent true then don't print any diagnostic
to the log
@return error number, or OS error number + 100 */
-static
-ulint
-os_file_get_last_error_low(
- bool report_all_errors,
- bool on_error_silent)
+ulint os_file_get_last_error(bool report_all_errors, bool on_error_silent)
{
int err = errno;
@@ -1801,16 +1794,13 @@ bool os_file_flush_func(os_file_t file)
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
then OS error number + OS_FILE_ERROR_MAX is returned.
-@param[in] report_all_errors true if we want an error message printed
- of all errors
+@param[in] report_all_errors true if we want an error message
+printed of all errors
@param[in] on_error_silent true then don't print any diagnostic
to the log
@return error number, or OS error number + OS_FILE_ERROR_MAX */
-static
-ulint
-os_file_get_last_error_low(
- bool report_all_errors,
- bool on_error_silent)
+ulint os_file_get_last_error(bool report_all_errors, bool on_error_silent)
+
{
ulint err = (ulint) GetLastError();
@@ -2928,20 +2918,6 @@ os_file_read_func(
return err ? err : DB_IO_ERROR;
}
-/** Retrieves the last error number if an error occurs in a file io function.
-The number should be retrieved before any other OS calls (because they may
-overwrite the error number). If the number is not known to this program,
-the OS error number + 100 is returned.
-@param[in] report_all_errors true if we want an error printed
- for all errors
-@return error number, or OS error number + 100 */
-ulint
-os_file_get_last_error(
- bool report_all_errors)
-{
- return(os_file_get_last_error_low(report_all_errors, false));
-}
-
/** Handle errors for file operations.
@param[in] name name of a file or NULL
@param[in] operation operation
@@ -2958,7 +2934,7 @@ os_file_handle_error_cond_exit(
{
ulint err;
- err = os_file_get_last_error_low(false, on_error_silent);
+ err = os_file_get_last_error(false, on_error_silent);
switch (err) {
case OS_FILE_DISK_FULL:
@@ -3447,9 +3423,8 @@ static void io_callback(tpool::aiocb *cb)
else
{
ut_ad(write_slots->contains(cb));
- const IORequest req{request};
+ fil_aio_callback(request);
write_slots->release(cb);
- fil_aio_callback(req);
}
}
@@ -3647,8 +3622,9 @@ more concurrent threads via thread_group setting.
int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads)
{
/* Lock the slots, and wait until all current IOs finish.*/
- std::unique_lock<std::mutex> lk_read(read_slots->mutex());
- std::unique_lock<std::mutex> lk_write(write_slots->mutex());
+ auto &lk_read= read_slots->mutex(), &lk_write= write_slots->mutex();
+ mysql_mutex_lock(&lk_read);
+ mysql_mutex_lock(&lk_write);
read_slots->wait(lk_read);
write_slots->wait(lk_write);
@@ -3661,20 +3637,25 @@ int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads)
/** Do the Linux AIO dance (this will try to create a new
io context with changed max_events ,etc*/
- if (int ret= srv_thread_pool->reconfigure_aio(srv_use_native_aio, events))
+ int ret= srv_thread_pool->reconfigure_aio(srv_use_native_aio, events);
+
+ if (ret)
{
/** Do the best effort. We can't change the parallel io number,
but we still can adjust the number of concurrent completion handlers.*/
read_slots->task_group().set_max_tasks(static_cast<int>(n_reader_threads));
write_slots->task_group().set_max_tasks(static_cast<int>(n_writer_threads));
- return ret;
+ }
+ else
+ {
+ /* Allocation succeeded, resize the slots*/
+ read_slots->resize(max_read_events, static_cast<int>(n_reader_threads));
+ write_slots->resize(max_write_events, static_cast<int>(n_writer_threads));
}
- /* Allocation succeeded, resize the slots*/
- read_slots->resize(max_read_events, static_cast<int>(n_reader_threads), lk_read);
- write_slots->resize(max_write_events, static_cast<int>(n_writer_threads), lk_write);
-
- return 0;
+ mysql_mutex_unlock(&lk_read);
+ mysql_mutex_unlock(&lk_write);
+ return ret;
}
void os_aio_free()
@@ -3687,9 +3668,9 @@ void os_aio_free()
}
/** Wait until there are no pending asynchronous writes. */
-static void os_aio_wait_until_no_pending_writes_low()
+static void os_aio_wait_until_no_pending_writes_low(bool declare)
{
- bool notify_wait = write_slots->pending_io_count() > 0;
+ const bool notify_wait= declare && write_slots->pending_io_count();
if (notify_wait)
tpool::tpool_wait_begin();
@@ -3700,17 +3681,43 @@ static void os_aio_wait_until_no_pending_writes_low()
tpool::tpool_wait_end();
}
-/** Wait until there are no pending asynchronous writes. */
-void os_aio_wait_until_no_pending_writes()
+/** Wait until there are no pending asynchronous writes.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_writes(bool declare)
{
- os_aio_wait_until_no_pending_writes_low();
+ os_aio_wait_until_no_pending_writes_low(declare);
buf_dblwr.wait_flush_buffered_writes();
}
-/** Wait until all pending asynchronous reads have completed. */
-void os_aio_wait_until_no_pending_reads()
+/** @return number of pending reads */
+size_t os_aio_pending_reads()
+{
+ mysql_mutex_lock(&read_slots->mutex());
+ size_t pending= read_slots->pending_io_count();
+ mysql_mutex_unlock(&read_slots->mutex());
+ return pending;
+}
+
+/** @return approximate number of pending reads */
+size_t os_aio_pending_reads_approx()
+{
+ return read_slots->pending_io_count();
+}
+
+/** @return number of pending writes */
+size_t os_aio_pending_writes()
+{
+ mysql_mutex_lock(&write_slots->mutex());
+ size_t pending= write_slots->pending_io_count();
+ mysql_mutex_unlock(&write_slots->mutex());
+ return pending;
+}
+
+/** Wait until all pending asynchronous reads have completed.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_reads(bool declare)
{
- const auto notify_wait= read_slots->pending_io_count();
+ const bool notify_wait= declare && read_slots->pending_io_count();
if (notify_wait)
tpool::tpool_wait_begin();