Commit 200cb823 authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

disk/aio: Fix AIO thread



Currently when the kernel completes a batch of AIO requests and signals it
via eventfd, we retrieve at most AIO_MAX events (256), and ignore the
rest. Call io_getevents() again in case more events are pending.
Reviewed-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent d62e8ee0
......@@ -66,20 +66,31 @@ ssize_t raw_image__write_async(struct disk_image *disk, u64 sector,
offset, disk->evt, param);
}
static void *disk_aio_thread(void *param)
static int disk_aio_get_events(struct disk_image *disk)
{
struct disk_image *disk = param;
struct io_event event[AIO_MAX];
struct timespec notime = {0};
int nr, i;
do {
nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, &notime);
for (i = 0; i < nr; i++)
disk->disk_req_cb(event[i].data, event[i].res);
} while (nr > 0);
return 0;
}
static void *disk_aio_thread(void *param)
{
struct disk_image *disk = param;
u64 dummy;
kvm__set_thread_name("disk-image-io");
while (read(disk->evt, &dummy, sizeof(dummy)) > 0) {
nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, &notime);
for (i = 0; i < nr; i++)
disk->disk_req_cb(event[i].data, event[i].res);
if (disk_aio_get_events(disk))
break;
}
return NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment