summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-03-30 11:26:09 +0100
committerJens Axboe <axboe@kernel.dk>2021-04-04 09:45:26 -0600
commitb75baa4f16d51c31f91a13f6ffd0918f99da97c8 (patch)
treeb869163ca2713964f18a1c37b76b0e561a779856
parenta209abe65befe603311b6fcd861e14d28e3e2f2d (diff)
downloadliburing-b75baa4f16d51c31f91a13f6ffd0918f99da97c8.tar.gz
liburing-b75baa4f16d51c31f91a13f6ffd0918f99da97c8.tar.bz2
tests: test CQE ordering on early submission fail
Check that CQEs of a link comes in the order of submission, even when a link fails early during submission initial prep. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/link.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/link.c b/test/link.c
index c89d6b2..fadd0b5 100644
--- a/test/link.c
+++ b/test/link.c
@@ -429,6 +429,53 @@ err:
return 1;
}
+static int test_link_fail_ordering(struct io_uring *ring)
+{
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ int ret, i, nr_compl;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_nop(sqe);
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 0;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_write(sqe, -1, NULL, 100, 0);
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 1;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_nop(sqe);
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 2;
+
+ nr_compl = ret = io_uring_submit(ring);
+ /* at least the first nop should have been submitted */
+ if (ret < 1) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ goto err;
+ }
+
+ for (i = 0; i < nr_compl; i++) {
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ if (cqe->user_data != i) {
+ fprintf(stderr, "wrong CQE order, got %i, expected %i\n",
+ (int)cqe->user_data, i);
+ goto err;
+ }
+ io_uring_cqe_seen(ring, cqe);
+ }
+
+ return 0;
+err:
+ return 1;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring, poll_ring;
@@ -492,5 +539,11 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_link_fail_ordering(&ring);
+ if (ret) {
+ fprintf(stderr, "test_link_fail_ordering last failed\n");
+ return ret;
+ }
+
return 0;
}