public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing] tests: add IOSQE_ASYNC cancel testing
Date: Mon, 23 Aug 2021 12:16:56 +0100	[thread overview]
Message-ID: <b5dada6cba71207dd8b282a805714a4fe8db2258.1629717388.git.asml.silence@gmail.com> (raw)

We miss tests for IORING_OP_ASYNC_CANCEL requests issued with
IOSQE_ASYNC, so add it.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/io-cancel.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/test/io-cancel.c b/test/io-cancel.c
index a4cc361..63d2f7d 100644
--- a/test/io-cancel.c
+++ b/test/io-cancel.c
@@ -115,7 +115,7 @@ static int do_io(struct io_uring *ring, int fd, int do_write)
 	return 0;
 }
 
-static int start_cancel(struct io_uring *ring, int do_partial)
+static int start_cancel(struct io_uring *ring, int do_partial, int async_cancel)
 {
 	struct io_uring_sqe *sqe;
 	int i, ret, submitted = 0;
@@ -129,6 +129,8 @@ static int start_cancel(struct io_uring *ring, int do_partial)
 			goto err;
 		}
 		io_uring_prep_cancel(sqe, (void *) (unsigned long) i + 1, 0);
+		if (async_cancel)
+			sqe->flags |= IOSQE_ASYNC;
 		sqe->user_data = 0;
 		submitted++;
 	}
@@ -148,7 +150,8 @@ err:
  * the submitted IO. This is done to verify that cancelling one piece of IO doesn't
  * impact others.
  */
-static int test_io_cancel(const char *file, int do_write, int do_partial)
+static int test_io_cancel(const char *file, int do_write, int do_partial,
+			  int async_cancel)
 {
 	struct io_uring ring;
 	struct timeval start_tv;
@@ -179,7 +182,7 @@ static int test_io_cancel(const char *file, int do_write, int do_partial)
 		goto err;
 	/* sleep for 1/3 of the total time, to allow some to start/complete */
 	usleep(usecs / 3);
-	if (start_cancel(&ring, do_partial))
+	if (start_cancel(&ring, do_partial, async_cancel))
 		goto err;
 	to_wait = BUFFERS;
 	if (do_partial)
@@ -512,13 +515,15 @@ int main(int argc, char *argv[])
 
 	vecs = t_create_buffers(BUFFERS, BS);
 
-	for (i = 0; i < 4; i++) {
-		int v1 = (i & 1) != 0;
-		int v2 = (i & 2) != 0;
+	for (i = 0; i < 8; i++) {
+		int write = (i & 1) != 0;
+		int partial = (i & 2) != 0;
+		int async = (i & 4) != 0;
 
-		ret = test_io_cancel(".basic-rw", v1, v2);
+		ret = test_io_cancel(".basic-rw", write, partial, async);
 		if (ret) {
-			fprintf(stderr, "test_io_cancel %d %d failed\n", v1, v2);
+			fprintf(stderr, "test_io_cancel %d %d %d failed\n",
+				write, partial, async);
 			goto err;
 		}
 	}
-- 
2.32.0


             reply	other threads:[~2021-08-23 11:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 11:16 Pavel Begunkov [this message]
2021-08-23 16:17 ` [PATCH liburing] tests: add IOSQE_ASYNC cancel testing 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=b5dada6cba71207dd8b282a805714a4fe8db2258.1629717388.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