From: Wojciech Lukowicz <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], Wojciech Lukowicz <[email protected]>
Subject: [PATCH liburing] test/read-write: add test for CQE res when removing buffers
Date: Sat, 1 Apr 2023 20:52:59 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
When removing provided buffers, CQE res should contain the number of
removed buffers. However, in certain kernel versions, if SQE requests
removal of more buffers than available, then res will contain the number
of removed buffers + 1.
Signed-off-by: Wojciech Lukowicz <[email protected]>
---
This is a failing test, needs the patch I sent earlier.
test/read-write.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/test/read-write.c b/test/read-write.c
index 3764f6aef47e..6f24ec919de3 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -637,6 +637,53 @@ static int test_rem_buf(int batch, int sqe_flags)
return ret;
}
+static int test_rem_buf_single(int to_rem)
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring_cqe *cqe;
+ struct io_uring ring;
+ int ret, expected;
+ int bgid = 1;
+
+ if (no_buf_select)
+ return 0;
+
+ ret = io_uring_queue_init(64, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "ring create failed: %d\n", ret);
+ return 1;
+ }
+
+ ret = provide_buffers_iovec(&ring, bgid);
+ if (ret)
+ return ret;
+
+ expected = (to_rem > BUFFERS) ? BUFFERS : to_rem;
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_remove_buffers(sqe, to_rem, bgid);
+
+ ret = io_uring_submit(&ring);
+ if (ret != 1) {
+ fprintf(stderr, "submit: %d\n", ret);
+ return -1;
+ }
+
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "wait_cqe=%d\n", ret);
+ return 1;
+ }
+ if (cqe->res != expected) {
+ fprintf(stderr, "cqe->res=%d, expected=%d\n", cqe->res, expected);
+ return 1;
+ }
+ io_uring_cqe_seen(&ring, cqe);
+
+ io_uring_queue_exit(&ring);
+ return ret;
+}
+
static int test_io_link(const char *file)
{
const int nr_links = 100;
@@ -950,6 +997,12 @@ int main(int argc, char *argv[])
}
}
+ ret = test_rem_buf_single(BUFFERS + 1);
+ if (ret) {
+ fprintf(stderr, "test_rem_buf_single(BUFFERS + 1) failed\n");
+ goto err;
+ }
+
if (fname != argv[1])
unlink(fname);
return 0;
--
2.30.2
next reply other threads:[~2023-04-01 19:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 19:52 Wojciech Lukowicz [this message]
2023-04-01 23:20 ` [PATCH liburing] test/read-write: add test for CQE res when removing buffers Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox