From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 2/2] test: test fd msg-ring allocating indexes
Date: Thu, 16 Mar 2023 13:09:21 +0000 [thread overview]
Message-ID: <4f10e4213360871087bfb94f1e37c207c0f4ca51.1678968783.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
fd msg-ring requests supports IORING_FILE_INDEX_ALLOC, add a test for
that.
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/fd-pass.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/test/fd-pass.c b/test/fd-pass.c
index f3ede77..0c981fb 100644
--- a/test/fd-pass.c
+++ b/test/fd-pass.c
@@ -80,6 +80,14 @@ static int test(const char *filename, int source_fd, int target_fd)
fprintf(stderr, "register files failed %d\n", ret);
return T_EXIT_FAIL;
}
+ if (target_fd == IORING_FILE_INDEX_ALLOC) {
+ /* we want to test installing into a non-zero slot */
+ ret = io_uring_register_file_alloc_range(&dring, 1, 1);
+ if (ret) {
+ fprintf(stderr, "io_uring_register_file_alloc_range %d\n", ret);
+ return T_EXIT_FAIL;
+ }
+ }
/* open direct descriptor */
sqe = io_uring_get_sqe(&sring);
@@ -102,8 +110,14 @@ static int test(const char *filename, int source_fd, int target_fd)
/* send direct descriptor to destination ring */
sqe = io_uring_get_sqe(&sring);
- io_uring_prep_msg_ring_fd(sqe, dring.ring_fd, source_fd, target_fd,
- USER_DATA, 0);
+ if (target_fd == IORING_FILE_INDEX_ALLOC) {
+ io_uring_prep_msg_ring_fd_alloc(sqe, dring.ring_fd, source_fd,
+ USER_DATA, 0);
+ } else {
+
+ io_uring_prep_msg_ring_fd(sqe, dring.ring_fd, source_fd,
+ target_fd, USER_DATA, 0);
+ }
io_uring_submit(&sring);
ret = io_uring_wait_cqe(&sring, &cqe);
@@ -111,7 +125,7 @@ static int test(const char *filename, int source_fd, int target_fd)
fprintf(stderr, "wait cqe failed %d\n", ret);
return T_EXIT_FAIL;
}
- if (cqe->res) {
+ if (cqe->res < 0) {
if (cqe->res == -EINVAL && !no_fd_pass) {
no_fd_pass = 1;
return T_EXIT_SKIP;
@@ -131,6 +145,17 @@ static int test(const char *filename, int source_fd, int target_fd)
fprintf(stderr, "bad user_data %ld\n", (long) cqe->res);
return T_EXIT_FAIL;
}
+ if (cqe->res < 0) {
+ fprintf(stderr, "bad result %i\n", cqe->res);
+ return T_EXIT_FAIL;
+ }
+ if (target_fd == IORING_FILE_INDEX_ALLOC) {
+ if (cqe->res != 1) {
+ fprintf(stderr, "invalid allocated index %i\n", cqe->res);
+ return T_EXIT_FAIL;
+ }
+ target_fd = cqe->res;
+ }
io_uring_cqe_seen(&dring, cqe);
/* now verify we can read the sane data from the destination ring */
@@ -201,6 +226,12 @@ int main(int argc, char *argv[])
ret = T_EXIT_FAIL;
}
+ ret = test(fname, 1, IORING_FILE_INDEX_ALLOC);
+ if (ret == T_EXIT_FAIL) {
+ fprintf(stderr, "test failed 1 ALLOC\n");
+ ret = T_EXIT_FAIL;
+ }
+
unlink(fname);
return ret;
}
--
2.39.1
next prev parent reply other threads:[~2023-03-16 13:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 13:09 [PATCH liburing for-next 0/2] fd msg-ring slot allocation tests Pavel Begunkov
2023-03-16 13:09 ` [PATCH liburing 1/2] Add io_uring_prep_msg_ring_fd_alloc() helper Pavel Begunkov
2023-03-16 15:01 ` Jens Axboe
2023-03-16 13:09 ` Pavel Begunkov [this message]
2023-03-16 15:02 ` [PATCH liburing for-next 0/2] fd msg-ring slot allocation tests 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 \
--in-reply-to=4f10e4213360871087bfb94f1e37c207c0f4ca51.1678968783.git.asml.silence@gmail.com \
[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