Commit 543f22a2 authored by Eugene Kosov's avatar Eugene Kosov

check parameters of io_submit() and LinuxAIOHandler::reserve_slot()

Ensure that pointer to a buffer which is used for both reads and writes
is properly aligned.

I've intentially put permanent check right before io_submit() call instead
of the time of setting iocb date. I think that'll make check better.

LinuxAIOHandler::resever_slot(): check arguments alignment in debug builds
parent 88073dae
...@@ -1792,6 +1792,9 @@ LinuxAIOHandler::resubmit(Slot* slot) ...@@ -1792,6 +1792,9 @@ LinuxAIOHandler::resubmit(Slot* slot)
iocb->data = slot; iocb->data = slot;
ut_a(reinterpret_cast<size_t>(iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE
== 0);
/* Resubmit an I/O request */ /* Resubmit an I/O request */
int ret = io_submit(m_array->io_ctx(m_segment), 1, &iocb); int ret = io_submit(m_array->io_ctx(m_segment), 1, &iocb);
ut_a(ret != -EINVAL); ut_a(ret != -EINVAL);
...@@ -2160,6 +2163,9 @@ AIO::linux_dispatch(Slot* slot) ...@@ -2160,6 +2163,9 @@ AIO::linux_dispatch(Slot* slot)
io_ctx_index = (slot->pos * m_n_segments) / m_slots.size(); io_ctx_index = (slot->pos * m_n_segments) / m_slots.size();
ut_a(reinterpret_cast<size_t>(iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE
== 0);
int ret = io_submit(io_ctx(io_ctx_index), 1, &iocb); int ret = io_submit(io_ctx(io_ctx_index), 1, &iocb);
ut_a(ret != -EINVAL); ut_a(ret != -EINVAL);
...@@ -2352,6 +2358,8 @@ AIO::is_linux_native_aio_supported() ...@@ -2352,6 +2358,8 @@ AIO::is_linux_native_aio_supported()
io_prep_pread(p_iocb, fd, ptr, 512, 0); io_prep_pread(p_iocb, fd, ptr, 512, 0);
} }
ut_a(reinterpret_cast<size_t>(p_iocb->u.c.buf) % OS_FILE_LOG_BLOCK_SIZE
== 0);
int err = io_submit(io_ctx, 1, &p_iocb); int err = io_submit(io_ctx, 1, &p_iocb);
ut_a(err != -EINVAL); ut_a(err != -EINVAL);
...@@ -6271,6 +6279,10 @@ AIO::reserve_slot( ...@@ -6271,6 +6279,10 @@ AIO::reserve_slot(
os_offset_t offset, os_offset_t offset,
ulint len) ulint len)
{ {
ut_ad(reinterpret_cast<size_t>(buf) % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(offset % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(len % OS_FILE_LOG_BLOCK_SIZE == 0);
#ifdef WIN_ASYNC_IO #ifdef WIN_ASYNC_IO
ut_a((len & 0xFFFFFFFFUL) == len); ut_a((len & 0xFFFFFFFFUL) == len);
#endif /* WIN_ASYNC_IO */ #endif /* WIN_ASYNC_IO */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment