Skip to content

Commit

Permalink
virtio-blk: tolerate failure to set BlockBackend AioContext
Browse files Browse the repository at this point in the history
We no longer rely on setting the AioContext since the block layer
IO_CODE APIs can be called from any thread. Now it's just a hint to help
block jobs and other operations co-locate themselves in a thread with
the guest I/O requests. Keep going if setting the AioContext fails.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20240119135748.270944-6-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
stefanhaRH authored and kevmw committed Jan 26, 2024
1 parent 71ee0cd commit ea0736d
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions hw/block/virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1786,11 +1786,14 @@ static int virtio_blk_start_ioeventfd(VirtIODevice *vdev)

memory_region_transaction_commit();

/*
* Try to change the AioContext so that block jobs and other operations can
* co-locate their activity in the same AioContext. If it fails, nevermind.
*/
r = blk_set_aio_context(s->conf.conf.blk, s->vq_aio_context[0],
&local_err);
if (r < 0) {
error_report_err(local_err);
goto fail_aio_context;
warn_report_err(local_err);
}

/*
Expand Down Expand Up @@ -1819,18 +1822,6 @@ static int virtio_blk_start_ioeventfd(VirtIODevice *vdev)
}
return 0;

fail_aio_context:
memory_region_transaction_begin();

for (i = 0; i < nvqs; i++) {
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
}

memory_region_transaction_commit();

for (i = 0; i < nvqs; i++) {
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
}
fail_host_notifiers:
k->set_guest_notifiers(qbus->parent, nvqs, false);
fail_guest_notifiers:
Expand Down

0 comments on commit ea0736d

Please sign in to comment.