public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v2] test/drain: test draining linked timeouts
@ 2021-01-27  1:41 Pavel Begunkov
  2021-01-27  2:42 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-01-27  1:41 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Make sure references are accounted well when we defer reqs with linked
timeouts.

Signed-off-by: Pavel Begunkov <[email protected]>
---

v2: mark with IOSQE_IO_DRAIN all

 test/defer.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/test/defer.c b/test/defer.c
index 05833d4..98abfba 100644
--- a/test/defer.c
+++ b/test/defer.c
@@ -148,6 +148,38 @@ err:
 	return 1;
 }
 
+static int test_drain_with_linked_timeout(struct io_uring *ring)
+{
+	const int nr = 3;
+	struct __kernel_timespec ts = { .tv_sec = 1, .tv_nsec = 0, };
+	struct test_context ctx;
+	int ret, i;
+
+	if (init_context(&ctx, ring, nr * 2))
+		return 1;
+
+	for (i = 0; i < nr; i++) {
+		io_uring_prep_timeout(ctx.sqes[2 * i], &ts, 0, 0);
+		ctx.sqes[2 * i]->flags |= IOSQE_IO_LINK | IOSQE_IO_DRAIN;
+		io_uring_prep_link_timeout(ctx.sqes[2 * i + 1], &ts, 0);
+	}
+
+	ret = io_uring_submit(ring);
+	if (ret <= 0) {
+		printf("sqe submit failed: %d\n", ret);
+		goto err;
+	}
+
+	if (wait_cqes(&ctx))
+		goto err;
+
+	free_context(&ctx);
+	return 0;
+err:
+	free_context(&ctx);
+	return 1;
+}
+
 static int run_drained(struct io_uring *ring, int nr)
 {
 	struct test_context ctx;
@@ -269,5 +301,11 @@ int main(int argc, char *argv[])
 		return ret;
 	}
 
+	ret = test_drain_with_linked_timeout(&ring);
+	if (ret) {
+		printf("test_drain_with_linked_timeout failed\n");
+		return ret;
+	}
+
 	return 0;
 }
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] test/drain: test draining linked timeouts
  2021-01-27  1:41 [PATCH v2] test/drain: test draining linked timeouts Pavel Begunkov
@ 2021-01-27  2:42 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-01-27  2:42 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 1/26/21 6:41 PM, Pavel Begunkov wrote:
> Make sure references are accounted well when we defer reqs with linked
> timeouts.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-27  4:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-27  1:41 [PATCH v2] test/drain: test draining linked timeouts Pavel Begunkov
2021-01-27  2:42 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox