From: Dylan Yudaken <[email protected]>
To: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Cc: <[email protected]>, <[email protected]>,
Dylan Yudaken <[email protected]>
Subject: [PATCH liburing v2] test that unregister_files processes task work
Date: Tue, 8 Nov 2022 01:53:47 -0800 [thread overview]
Message-ID: <[email protected]> (raw)
Ensure that unregister_files processes task work from defer_taskrun even
when not explicitly flushed.
Signed-off-by: Dylan Yudaken <[email protected]>
---
v2:
- fix return code when ring init fails
test/file-register.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/test/file-register.c b/test/file-register.c
index 634ef8159cec..975f89d5a94b 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -935,6 +935,55 @@ static int test_zero_range_alloc(struct io_uring *ring, int fds[2])
return 0;
}
+static int test_defer_taskrun(void)
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring ring;
+ int ret, fds[2];
+ char buff = 'x';
+
+ ret = io_uring_queue_init(8, &ring,
+ IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SINGLE_ISSUER);
+ if (ret) {
+ fprintf(stderr, "ring init\n");
+ return 1;
+ }
+
+ ret = pipe(fds);
+ if (ret) {
+ fprintf(stderr, "bad pipes\n");
+ return 1;
+ }
+
+ ret = io_uring_register_files(&ring, &fds[0], 2);
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_read(sqe, 0, &buff, 1, 0);
+ sqe->flags |= IOSQE_FIXED_FILE;
+ ret = io_uring_submit(&ring);
+ if (ret != 1) {
+ fprintf(stderr, "bad submit\n");
+ return 1;
+ }
+
+ ret = write(fds[1], &buff, 1);
+ if (ret != 1) {
+ fprintf(stderr, "bad pipe write\n");
+ return 1;
+ }
+
+ ret = io_uring_unregister_files(&ring);
+ if (ret) {
+ fprintf(stderr, "bad unregister %d\n", ret);
+ return 1;
+ }
+
+ close(fds[0]);
+ close(fds[1]);
+ io_uring_queue_exit(&ring);
+ return 0;
+}
+
static int test_file_alloc_ranges(void)
{
struct io_uring ring;
@@ -1120,5 +1169,13 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}
+ if (t_probe_defer_taskrun()) {
+ ret = test_defer_taskrun();
+ if (ret) {
+ fprintf(stderr, "test_defer_taskrun failed\n");
+ return T_EXIT_FAIL;
+ }
+ }
+
return T_EXIT_PASS;
}
base-commit: 754bc068ec482c5338a07dd74b7d3892729bb847
--
2.30.2
next reply other threads:[~2022-11-08 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 9:53 Dylan Yudaken [this message]
2022-11-08 10:03 ` [PATCH liburing v2] test that unregister_files processes task work Ammar Faizi
2022-11-08 10:23 ` Dylan Yudaken
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] \
[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