summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2022-03-12 16:16:03 +1100
committerDaniel Black <daniel@mariadb.org>2022-03-12 16:16:03 +1100
commitbd1ba7801fc0a69c145dba8b825944f58e22449d (patch)
treee03cf936c2b868636808782c3ad5525c3fc1a324
parent77c7390fc8cdcf1373c1277ebb129a13575a3a5b (diff)
parentd78173828e9f69ab3f6a406cb38f323261171076 (diff)
downloadmariadb-git-bd1ba7801fc0a69c145dba8b825944f58e22449d.tar.gz
Merge branch 10.5 into 10.6
-rw-r--r--storage/innobase/buf/buf0rea.cc2
-rw-r--r--storage/innobase/os/os0file.cc2
-rw-r--r--tpool/aio_linux.cc2
-rw-r--r--tpool/aio_simulated.cc27
-rw-r--r--tpool/tpool.h6
-rw-r--r--tpool/tpool_generic.cc52
6 files changed, 62 insertions, 29 deletions
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index aafd1c048e4..f47c983c650 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -290,7 +290,7 @@ nothing_read:
/* Trx sys header is so low in the latching order that we play
safe and do not leave the i/o-completion to an asynchronous
i/o-thread. Change buffer pages must always be read with
- syncronous i/o, to make sure they do not get involved in
+ synchronous i/o, to make sure they do not get involved in
thread deadlocks. */
sync = true;
}
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 158cd4280b5..103cfb7a052 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -2785,7 +2785,7 @@ os_file_set_eof(
#endif /* !_WIN32*/
-/** Does a syncronous read or write depending upon the type specified
+/** Does a synchronous read or write depending upon the type specified
In case of partial reads/writes the function tries
NUM_RETRIES_ON_PARTIAL_IO times to read/write the complete data.
@param[in] type, IO flags
diff --git a/tpool/aio_linux.cc b/tpool/aio_linux.cc
index 4abc2139881..fc6e5b53e1a 100644
--- a/tpool/aio_linux.cc
+++ b/tpool/aio_linux.cc
@@ -128,6 +128,8 @@ class aio_linux final : public aio
{
iocb->m_ret_len= event.res;
iocb->m_err= 0;
+ if (iocb->m_ret_len != iocb->m_len)
+ finish_synchronous(iocb);
}
iocb->m_internal_task.m_func= iocb->m_callback;
iocb->m_internal_task.m_arg= iocb;
diff --git a/tpool/aio_simulated.cc b/tpool/aio_simulated.cc
index 6b6fe71c8ab..4bc58c2930c 100644
--- a/tpool/aio_simulated.cc
+++ b/tpool/aio_simulated.cc
@@ -136,32 +136,7 @@ public:
static void simulated_aio_callback(void *param)
{
aiocb *cb= (aiocb *) param;
-#ifdef _WIN32
- size_t ret_len;
-#else
- ssize_t ret_len;
-#endif
- int err= 0;
- switch (cb->m_opcode)
- {
- case aio_opcode::AIO_PREAD:
- ret_len= pread(cb->m_fh, cb->m_buffer, cb->m_len, cb->m_offset);
- break;
- case aio_opcode::AIO_PWRITE:
- ret_len= pwrite(cb->m_fh, cb->m_buffer, cb->m_len, cb->m_offset);
- break;
- default:
- abort();
- }
-#ifdef _WIN32
- if (static_cast<int>(ret_len) < 0)
- err= GetLastError();
-#else
- if (ret_len < 0)
- err= errno;
-#endif
- cb->m_ret_len = ret_len;
- cb->m_err = err;
+ synchronous(cb);
cb->m_internal_task.m_func= cb->m_callback;
thread_pool *pool= (thread_pool *)cb->m_internal;
pool->submit_task(&cb->m_internal_task);
diff --git a/tpool/tpool.h b/tpool/tpool.h
index f857dddd57a..2c61c2d62b2 100644
--- a/tpool/tpool.h
+++ b/tpool/tpool.h
@@ -161,7 +161,7 @@ class aio
{
public:
/**
- Submit asyncronous IO.
+ Submit asynchronous IO.
On completion, cb->m_callback is executed.
*/
virtual int submit_io(aiocb *cb)= 0;
@@ -170,6 +170,10 @@ public:
/** "Unind" file to AIO handler (used on Windows only) */
virtual int unbind(const native_file_handle &fd)= 0;
virtual ~aio(){};
+protected:
+ static void synchronous(aiocb *cb);
+ /** finish a partial read/write callback synchronously */
+ static void finish_synchronous(aiocb *cb);
};
class timer
diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc
index ecc489c3357..a1b9a3ce945 100644
--- a/tpool/tpool_generic.cc
+++ b/tpool/tpool_generic.cc
@@ -52,6 +52,58 @@ namespace tpool
static const int OVERSUBSCRIBE_FACTOR = 2;
/**
+ Process the cb synchronously
+*/
+void aio::synchronous(aiocb *cb)
+{
+#ifdef _WIN32
+ size_t ret_len;
+#else
+ ssize_t ret_len;
+#endif
+ int err= 0;
+ switch (cb->m_opcode)
+ {
+ case aio_opcode::AIO_PREAD:
+ ret_len= pread(cb->m_fh, cb->m_buffer, cb->m_len, cb->m_offset);
+ break;
+ case aio_opcode::AIO_PWRITE:
+ ret_len= pwrite(cb->m_fh, cb->m_buffer, cb->m_len, cb->m_offset);
+ break;
+ default:
+ abort();
+ }
+#ifdef _WIN32
+ if (static_cast<int>(ret_len) < 0)
+ err= GetLastError();
+#else
+ if (ret_len < 0)
+ {
+ err= errno;
+ ret_len= 0;
+ }
+#endif
+ cb->m_ret_len = ret_len;
+ cb->m_err = err;
+ if (!err && cb->m_ret_len != cb->m_len)
+ finish_synchronous(cb);
+}
+
+
+/**
+ A partial read/write has occured, continue synchronously.
+*/
+void aio::finish_synchronous(aiocb *cb)
+{
+ assert(cb->m_ret_len != (unsigned int) cb->m_len && !cb->m_err);
+ /* partial read/write */
+ cb->m_buffer= (char *) cb->m_buffer + cb->m_ret_len;
+ cb->m_len-= (unsigned int) cb->m_ret_len;
+ cb->m_offset+= cb->m_ret_len;
+ synchronous(cb);
+}
+
+/**
Implementation of generic threadpool.
This threadpool consists of the following components