Skip to content

Commit

Permalink
Update iouring-wrapper.cpp (#176)
Browse files Browse the repository at this point in the history
The io_uring wait timeout bug has been backport to kernel 5.15 in earlier 2023
  • Loading branch information
beef9999 authored Aug 16, 2023
1 parent 01532bb commit 93125ee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions io/iouring-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine {
// Batch submit all SQEs
int ret = io_uring_submit_and_wait(ring, 1);
if (ret <= 0) {
LOG_ERROR_RETURN(0, -1, "iouring: failed to submit io")
LOG_ERRNO_RETURN(0, -1, "iouring: failed to submit io")
}
return 0;
}
Expand All @@ -455,7 +455,7 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine {
// Batch submit all SQEs
int ret = io_uring_submit_and_wait_timeout(ring, cqe, 1, ts, nullptr);
if (ret < 0 && ret != -ETIME) {
LOG_ERROR_RETURN(0, -1, "iouring: failed to submit io");
LOG_ERRNO_RETURN(0, -1, "iouring: failed to submit io");
}
return 0;
}
Expand All @@ -465,12 +465,13 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine {

static void set_submit_wait_function() {
// The submit_and_wait_timeout API is more efficient than setting up a timer and waiting for it.
// But there is a kernel bug before 5.17, so choose appropriate function here.
// But there is a kernel bug before 5.15, so choose appropriate function here.
// See https://git.kernel.dk/cgit/linux-block/commit/?h=io_uring-5.17&id=228339662b398a59b3560cd571deb8b25b253c7e
// and https://www.spinics.net/lists/stable/msg620268.html
if (m_submit_wait_func)
return;
int result;
if (kernel_version_compare("5.17", result) == 0 && result >= 0) {
if (kernel_version_compare("5.15", result) == 0 && result >= 0) {
m_submit_wait_func = submit_wait_by_api;
} else {
m_submit_wait_func = submit_wait_by_timer;
Expand Down

0 comments on commit 93125ee

Please sign in to comment.