Skip to content

Commit

Permalink
Handle -EAGAIN from io_submit()
Browse files Browse the repository at this point in the history
If io_submit() returns -EAGAIN, that just means the io context is full
and we need to wait for completions - no need to die.

Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
Kent Overstreet committed Sep 29, 2023
1 parent 5e21565 commit 6b175a0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion linux/blkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ static void sync_write(struct bio *bio, struct iovec * iov, unsigned i)
sync_check(bio, ret);
}

static DECLARE_WAIT_QUEUE_HEAD(aio_events_completed);

static int aio_completion_thread(void *arg)
{
struct io_event events[8], *ev;
Expand All @@ -303,6 +305,8 @@ static int aio_completion_thread(void *arg)
continue;
if (ret < 0)
die("io_getevents() error: %s", strerror(-ret));
if (ret)
wake_up(&aio_events_completed);

for (ev = events; ev < events + ret; ev++) {
struct bio *bio = (struct bio *) ev->data;
Expand Down Expand Up @@ -394,7 +398,10 @@ static void aio_op(struct bio *bio, struct iovec *iov, unsigned i, int opcode)
}, *iocbp = &iocb;

atomic_inc(&running_requests);
ret = io_submit(aio_ctx, 1, &iocbp);

wait_event(aio_events_completed,
(ret = io_submit(aio_ctx, 1, &iocbp)) != -EAGAIN);;

if (ret != 1)
die("io_submit err: %s", strerror(-ret));
}
Expand Down

0 comments on commit 6b175a0

Please sign in to comment.