blob: 8aea3abac9fa0dbfe28abcbf593c037a16f07248 [file] [log] [blame]
From 1e6918419f4a2e5dbd77dd2da82598f1af63f533 Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@kernel.dk>
Date: Wed, 24 Aug 2022 12:01:39 -0600
Subject: [PATCH] engines/io_uring: pass back correct error value when
interrupted
Running with an io_uring engine and using a USR1 signal to show
current status will end up terminating the job with:
fio: pid=91726, err=-4/file:ioengines.c:320, func=get_events, error=Unknown error -4
sfx: (groupid=0, jobs=1): err=-4 (file:ioengines.c:320, func=get_events, error=Unknown error -4): pid=91726: Wed Aug 24 11:59:51 2022
Ensure that the return value is set correctly based on the errno.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
engines/io_uring.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/engines/io_uring.c b/engines/io_uring.c
index cffc7371..89d64b06 100644
--- a/engines/io_uring.c
+++ b/engines/io_uring.c
@@ -445,12 +445,18 @@ static struct io_u *fio_ioring_event(struct thread_data *td, int event)
struct io_uring_cqe *cqe;
struct io_u *io_u;
unsigned index;
+ static int eio;
index = (event + ld->cq_ring_off) & ld->cq_ring_mask;
cqe = &ld->cq_ring.cqes[index];
io_u = (struct io_u *) (uintptr_t) cqe->user_data;
+ if (eio++ == 5) {
+ printf("mark EIO\n");
+ cqe->res = -EIO;
+ }
+
if (cqe->res != io_u->xfer_buflen) {
if (cqe->res > io_u->xfer_buflen)
io_u->error = -cqe->res;
@@ -532,6 +538,7 @@ static int fio_ioring_getevents(struct thread_data *td, unsigned int min,
if (r < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
+ r = -errno;
td_verror(td, errno, "io_uring_enter");
break;
}
@@ -665,6 +672,7 @@ static int fio_ioring_commit(struct thread_data *td)
usleep(1);
continue;
}
+ ret = -errno;
td_verror(td, errno, "io_uring_enter submit");
break;
}