diff --git a/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch b/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch new file mode 100644 index 0000000000000000000000000000000000000000..f77be96269a83255ebec24acefba35e916d4b72d --- /dev/null +++ b/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch @@ -0,0 +1,57 @@ +From 626d52adaffc193597ff0294be50611540a6233c Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Wed, 30 Nov 2022 20:37:12 -0700 +Subject: [PATCH 1/4] test/io_uring_passthrough: skip if kernel doesn't support + passthrough + +If we get -EOPNOTSUPP, just skip the test at our earliest convenience. + +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index ee9ab87..2f24364 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -18,6 +18,7 @@ + #define BUFFERS (FILE_SIZE / BS) + + static struct iovec *vecs; ++static int no_pt; + + /* + * Each offset in the file has the ((test_case / 2) * FILE_SIZE) +@@ -205,6 +206,10 @@ static int __test_io(const char *file, struct io_uring *ring, int tc, int read, + goto err; + } + if (cqe->res != 0) { ++ if (!no_pt) { ++ no_pt = 1; ++ goto skip; ++ } + fprintf(stderr, "cqe res %d, wanted 0\n", cqe->res); + goto err; + } +@@ -234,6 +239,7 @@ static int __test_io(const char *file, struct io_uring *ring, int tc, int read, + } + } + ++skip: + close(fd); + return 0; + err: +@@ -431,6 +437,8 @@ int main(int argc, char *argv[]) + read, sqthread, fixed, nonvec); + goto err; + } ++ if (no_pt) ++ return T_EXIT_SKIP; + } + + ret = test_io_uring_submit_enters(fname); +-- +2.24.4 + diff --git a/1006-test-io_uring_passthrough-fix-iopoll-test.patch b/1006-test-io_uring_passthrough-fix-iopoll-test.patch new file mode 100644 index 0000000000000000000000000000000000000000..18944ced67b437f1ebbbaad062f21da5b53b7825 --- /dev/null +++ b/1006-test-io_uring_passthrough-fix-iopoll-test.patch @@ -0,0 +1,65 @@ +From 49425e0b44cf7b46f022ddabee73a0630cb1f9bc Mon Sep 17 00:00:00 2001 +From: Kanchan Joshi +Date: Tue, 6 Dec 2022 17:48:30 +0530 +Subject: [PATCH 2/4] test/io_uring_passthrough: fix iopoll test + +iopoll test is broken as it does not initialize the command/sqe properly +before submission. +Add the necessary initialization to set this right. + +Signed-off-by: Kanchan Joshi +Link: https://lore.kernel.org/r/20221206121831.5528-2-joshi.k@samsung.com +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 24 +++++++++++++++++++++--- + 1 file changed, 21 insertions(+), 3 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 2f24364..933c137 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -352,6 +352,8 @@ static int test_io_uring_submit_enters(const char *file) + int fd, i, ret, ring_flags, open_flags; + unsigned head; + struct io_uring_cqe *cqe; ++ struct nvme_uring_cmd *cmd; ++ struct io_uring_sqe *sqe; + + ring_flags = IORING_SETUP_IOPOLL; + ring_flags |= IORING_SETUP_SQE128; +@@ -371,12 +373,28 @@ static int test_io_uring_submit_enters(const char *file) + } + + for (i = 0; i < BUFFERS; i++) { +- struct io_uring_sqe *sqe; + off_t offset = BS * (rand() % BUFFERS); ++ __u64 slba; ++ __u32 nlb; + + sqe = io_uring_get_sqe(&ring); +- io_uring_prep_writev(sqe, fd, &vecs[i], 1, offset); +- sqe->user_data = 1; ++ io_uring_prep_readv(sqe, fd, &vecs[i], 1, offset); ++ sqe->user_data = i; ++ sqe->opcode = IORING_OP_URING_CMD; ++ sqe->cmd_op = NVME_URING_CMD_IO; ++ cmd = (struct nvme_uring_cmd *)sqe->cmd; ++ memset(cmd, 0, sizeof(struct nvme_uring_cmd)); ++ ++ slba = offset >> lba_shift; ++ nlb = (BS >> lba_shift) - 1; ++ ++ cmd->opcode = nvme_cmd_read; ++ cmd->cdw10 = slba & 0xffffffff; ++ cmd->cdw11 = slba >> 32; ++ cmd->cdw12 = nlb; ++ cmd->addr = (__u64)(uintptr_t)&vecs[i]; ++ cmd->data_len = 1; ++ cmd->nsid = nsid; + } + + /* submit manually to avoid adding IORING_ENTER_GETEVENTS */ +-- +2.24.4 + diff --git a/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch b/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch new file mode 100644 index 0000000000000000000000000000000000000000..676472b90868e34c8f6f4d00fa04d27c9e0dd73e --- /dev/null +++ b/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch @@ -0,0 +1,33 @@ +From 1985fba0acdac7addc3d8abb5db350a2a7648f16 Mon Sep 17 00:00:00 2001 +From: Kanchan Joshi +Date: Tue, 6 Dec 2022 17:48:31 +0530 +Subject: [PATCH 3/4] test/io_uring_passthrough: cleanup invalid submission + test + +Just do away with setting IOPOLL as this is not necessary for the test. + +Signed-off-by: Kanchan Joshi +Link: https://lore.kernel.org/r/20221206121831.5528-3-joshi.k@samsung.com +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 933c137..292e98d 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -288,8 +288,7 @@ static int test_invalid_passthru_submit(const char *file) + struct io_uring_sqe *sqe; + struct nvme_uring_cmd *cmd; + +- ring_flags = IORING_SETUP_IOPOLL | IORING_SETUP_SQE128; +- ring_flags |= IORING_SETUP_CQE32; ++ ring_flags = IORING_SETUP_CQE32 | IORING_SETUP_SQE128; + + ret = t_create_ring(1, &ring, ring_flags); + if (ret != T_SETUP_OK) { +-- +2.24.4 + diff --git a/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch b/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a9f5cc3038edb22cf4c483a27e8d4568d659c9b --- /dev/null +++ b/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch @@ -0,0 +1,51 @@ +From a0226c19959dda7e1008d0ff77f57264d7f7fdef Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Fri, 23 Dec 2022 08:55:41 -0700 +Subject: [PATCH 4/4] test/io_uring_passthrough: skip test if bit sqe/cqe + support not there + +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 292e98d..8fbafdb 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -264,6 +264,10 @@ static int test_io(const char *file, int tc, int read, int sqthread, + if (ret == T_SETUP_SKIP) + return 0; + if (ret != T_SETUP_OK) { ++ if (ret == -EINVAL) { ++ no_pt = 1; ++ return T_SETUP_SKIP; ++ } + fprintf(stderr, "ring create failed: %d\n", ret); + return 1; + } +@@ -449,15 +453,18 @@ int main(int argc, char *argv[]) + int nonvec = (i & 8) != 0; + + ret = test_io(fname, i, read, sqthread, fixed, nonvec); ++ if (no_pt) ++ break; + if (ret) { + fprintf(stderr, "test_io failed %d/%d/%d/%d\n", + read, sqthread, fixed, nonvec); + goto err; + } +- if (no_pt) +- return T_EXIT_SKIP; + } + ++ if (no_pt) ++ return T_EXIT_SKIP; ++ + ret = test_io_uring_submit_enters(fname); + if (ret) { + fprintf(stderr, "test_io_uring_submit_enters failed\n"); +-- +2.24.4 + diff --git a/liburing.spec b/liburing.spec index 5e766857d007d28d628035f6eafd5b937d749c75..fcba43aa8f31c912689ef26ed937b728a46c5609 100644 --- a/liburing.spec +++ b/liburing.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 Name: liburing Version: 2.3 Release: %{anolis_release}%{?dist} @@ -14,6 +14,10 @@ Patch1001: 1001-Add-percpu-io-sq-thread-support.patch Patch1002: 1002-support-us-granularity-of-io_sq_thread_idle.patch Patch1003: 1003-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch Patch1004: 1004-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch +Patch1005: 1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch +Patch1006: 1006-test-io_uring_passthrough-fix-iopoll-test.patch +Patch1007: 1007-test-io_uring_passthrough-cleanup-invalid-submission.patch +Patch1008: 1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch # End: Anolis customized patches %description @@ -60,6 +64,9 @@ for the Linux-native io_uring. %{_mandir}/man7/* %changelog +* Tue Jun 20 2023 Joseph Qi - 2.3-2 +- update io_uring_passthrough testcase + * Thu Dec 1 2022 Ziyang Zhang - 2.3-1 - upgrade to 2.3 and add anolis liburing features