From 571ae76c18afb74bd492aee0ba18ee52beaa484b Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Tue, 6 Jul 2021 18:32:27 +0200 Subject: [PATCH] [IO] document and adjust tests to changes in io_uring's broken link handling Until kernel commit cf10960426515 io_uring submitted sqe until it encountered an invalid one. Now io_uring will catch the error on subimssion and will cancel all sqe's contained in the link prior to the invalid one. --- emper/io/IoContext.cpp | 9 +++++++-- tests/io/LinkFutureTest.cpp | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/emper/io/IoContext.cpp b/emper/io/IoContext.cpp index bc5300f8..473f8924 100644 --- a/emper/io/IoContext.cpp +++ b/emper/io/IoContext.cpp @@ -133,13 +133,18 @@ void IoContext::submit(Future &future) { // Because we submit every Future right away multiple prepared sqes can only // occur for Future chains. // If we could not submit the whole chain cancel all non submitted Futures - // because we can not guaranty the soundness of the chain and invalidate their - // prepared sqe + // because we can not guaranty the soundness of the chain have to invalidate + // non submitted but prepared sqes // req1 -> invalid_req -> req3 // will submit only 2 instead of all 3 prepared sqes leaving a sqe for req3 // in the SQ but unsubmitted // See: https://github.com/axboe/liburing/issues/186 // https://github.com/axboe/liburing/issues/92 + // + // Since kernel commit cf10960426515 io_uring does no longer submit parts of a + // broken chains. This means that all sqes in a chain except the broken one will + // result in cqes with result -ECANCELD and the invalid one will + // generate a cqe with the appropriate error code if (unlikely(static_cast<unsigned>(submitted) < prepared)) { unsigned unsubmitted = io_uring_sq_ready(&ring); Future *unsubmittedFuture = &future; diff --git a/tests/io/LinkFutureTest.cpp b/tests/io/LinkFutureTest.cpp index 14c15cb0..94291c21 100644 --- a/tests/io/LinkFutureTest.cpp +++ b/tests/io/LinkFutureTest.cpp @@ -119,7 +119,10 @@ static void failureChainCorInvCor() { assert(res == -EBADF); res = correctFuture1.wait(); - assert(res == (int32_t)buf.size()); + // Since the kernel commit cf10960426515 io_uring does not + // submit broken links and completes any request before a + // invalid one as canceled. + assert(res == -ECANCELED || res == (int32_t)buf.size()); emper::io::closeAndWait(fd); } -- GitLab