From a8f6714e91d58f4a2eff4198b9f09c89df75f5cb Mon Sep 17 00:00:00 2001 From: Leah Rumancik Date: Fri, 7 Apr 2023 13:41:03 -0700 Subject: [PATCH] engines/libaio: fix io_getevents min/max events arguments If the io_getevents system call is interrupted, it can succeed while returning less than the min_nr requested events. If this occurs during the final reaping of events, libaio will call io_getevents again wtih the same minimum events argument. Since some of the events have already been reaped, this results in a hang. To fix this, update the arguments for io_getevents based on the previously seen events. Signed-off-by: Leah Rumancik --- engines/libaio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/libaio.c b/engines/libaio.c index 33b8c12f..1b82c90b 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -288,14 +288,16 @@ static int fio_libaio_getevents(struct thread_data *td, unsigned int min, && actual_min == 0 && ((struct aio_ring *)(ld->aio_ctx))->magic == AIO_RING_MAGIC) { - r = user_io_getevents(ld->aio_ctx, max, + r = user_io_getevents(ld->aio_ctx, max - events, ld->aio_events + events); } else { r = io_getevents(ld->aio_ctx, actual_min, - max, ld->aio_events + events, lt); + max - events, ld->aio_events + events, lt); } - if (r > 0) + if (r > 0) { events += r; + actual_min = actual_min > events ? actual_min - events : 0; + } else if ((min && r == 0) || r == -EAGAIN) { fio_libaio_commit(td); if (actual_min) -- 2.25.1