Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tpool/aio_liburing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/

namespace
{
using namespace tpool;

class aio_uring final : public tpool::aio
class aio_uring final : public aio
{
public:
aio_uring(tpool::thread_pool *tpool, int max_aio) : tpool_(tpool)
aio_uring(thread_pool *tpool, int max_aio) : tpool_(tpool)
{
if (const auto e= io_uring_queue_init(max_aio, &uring_, 0))
{
Expand Down Expand Up @@ -71,6 +72,9 @@ class aio_uring final : public tpool::aio
}
throw std::runtime_error("aio_uring()");
}
#if __has_feature(memory_sanitizer)
MEM_MAKE_DEFINED(&uring_, sizeof(uring_));
#endif
Comment on lines +75 to +77
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced the problem on clang 19 and successfully tested the fix. The patch that I tested also included the following compensation for the addition of using namespace tpool:

@@ -102,7 +106,7 @@ class aio_uring final : public tpool::aio
     io_uring_queue_exit(&uring_);
   }
 
-  int submit_io(tpool::aiocb *cb) final
+  int submit_io(aiocb *cb) final
   {
     cb->iov_base= cb->m_buffer;
     cb->iov_len= cb->m_len;
@@ -112,7 +116,7 @@ class aio_uring final : public tpool::aio
     std::lock_guard<std::mutex> _(mutex_);
 
     io_uring_sqe *sqe= io_uring_get_sqe(&uring_);
-    if (cb->m_opcode == tpool::aio_opcode::AIO_PREAD)
+    if (cb->m_opcode == aio_opcode::AIO_PREAD)
       io_uring_prep_readv(sqe, cb->m_fh, static_cast<struct iovec *>(cb), 1,
                           cb->m_offset);
     else
@@ -159,7 +163,7 @@ class aio_uring final : public tpool::aio
         abort();
       }
 
-      auto *iocb= static_cast<tpool::aiocb*>(io_uring_cqe_get_data(cqe));
+      auto *iocb= static_cast<aiocb*>(io_uring_cqe_get_data(cqe));
       if (!iocb)
         break; // ~aio_uring() told us to terminate
 

if (io_uring_ring_dontfork(&uring_) != 0)
{
my_printf_error(ER_UNKNOWN_ERROR,
Expand Down Expand Up @@ -102,7 +106,7 @@ class aio_uring final : public tpool::aio
io_uring_queue_exit(&uring_);
}

int submit_io(tpool::aiocb *cb) final
int submit_io(aiocb *cb) final
{
cb->iov_base= cb->m_buffer;
cb->iov_len= cb->m_len;
Expand All @@ -112,7 +116,7 @@ class aio_uring final : public tpool::aio
std::lock_guard<std::mutex> _(mutex_);

io_uring_sqe *sqe= io_uring_get_sqe(&uring_);
if (cb->m_opcode == tpool::aio_opcode::AIO_PREAD)
if (cb->m_opcode == aio_opcode::AIO_PREAD)
io_uring_prep_readv(sqe, cb->m_fh, static_cast<struct iovec *>(cb), 1,
cb->m_offset);
else
Expand Down Expand Up @@ -159,7 +163,7 @@ class aio_uring final : public tpool::aio
abort();
}

auto *iocb= static_cast<tpool::aiocb*>(io_uring_cqe_get_data(cqe));
auto *iocb= static_cast<aiocb*>(io_uring_cqe_get_data(cqe));
if (!iocb)
break; // ~aio_uring() told us to terminate

Expand Down Expand Up @@ -196,7 +200,7 @@ class aio_uring final : public tpool::aio

io_uring uring_;
std::mutex mutex_;
tpool::thread_pool *tpool_;
thread_pool *tpool_;
std::thread thread_;

std::vector<native_file_handle> files_;
Expand Down