Skip to content

Commit

Permalink
aio: remove aio_disable_external() API
Browse files Browse the repository at this point in the history
All callers now pass is_external=false to aio_set_fd_handler() and
aio_set_event_notifier(). The aio_disable_external() API that
temporarily disables fd handlers that were registered is_external=true
is therefore dead code.

Remove aio_disable_external(), aio_enable_external(), and the
is_external arguments to aio_set_fd_handler() and
aio_set_event_notifier().

The entire test-fdmon-epoll test is removed because its sole purpose was
testing aio_disable_external().

Parts of this patch were generated using the following coccinelle
(https://coccinelle.lip6.fr/) semantic patch:

  @@
  expression ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque;
  @@
  - aio_set_fd_handler(ctx, fd, is_external, io_read, io_write, io_poll, io_poll_ready, opaque)
  + aio_set_fd_handler(ctx, fd, io_read, io_write, io_poll, io_poll_ready, opaque)

  @@
  expression ctx, notifier, is_external, io_read, io_poll, io_poll_ready;
  @@
  - aio_set_event_notifier(ctx, notifier, is_external, io_read, io_poll, io_poll_ready)
  + aio_set_event_notifier(ctx, notifier, io_read, io_poll, io_poll_ready)

Reviewed-by: Juan Quintela <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
stefanhaRH authored and kevmw committed May 30, 2023
1 parent 03d7162 commit 60f782b
Show file tree
Hide file tree
Showing 36 changed files with 80 additions and 298 deletions.
7 changes: 0 additions & 7 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -7305,9 +7305,6 @@ static void bdrv_detach_aio_context(BlockDriverState *bs)
bs->drv->bdrv_detach_aio_context(bs);
}

if (bs->quiesce_counter) {
aio_enable_external(bs->aio_context);
}
bs->aio_context = NULL;
}

Expand All @@ -7317,10 +7314,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
BdrvAioNotifier *ban, *ban_tmp;
GLOBAL_STATE_CODE();

if (bs->quiesce_counter) {
aio_disable_external(new_context);
}

bs->aio_context = new_context;

if (bs->drv && bs->drv->bdrv_attach_aio_context) {
Expand Down
15 changes: 5 additions & 10 deletions block/blkio.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,23 +306,18 @@ static void blkio_attach_aio_context(BlockDriverState *bs,
{
BDRVBlkioState *s = bs->opaque;

aio_set_fd_handler(new_context,
s->completion_fd,
false,
blkio_completion_fd_read,
NULL,
aio_set_fd_handler(new_context, s->completion_fd,
blkio_completion_fd_read, NULL,
blkio_completion_fd_poll,
blkio_completion_fd_poll_ready,
bs);
blkio_completion_fd_poll_ready, bs);
}

static void blkio_detach_aio_context(BlockDriverState *bs)
{
BDRVBlkioState *s = bs->opaque;

aio_set_fd_handler(bdrv_get_aio_context(bs),
s->completion_fd,
false, NULL, NULL, NULL, NULL, NULL);
aio_set_fd_handler(bdrv_get_aio_context(bs), s->completion_fd, NULL, NULL,
NULL, NULL, NULL);
}

/* Call with s->blkio_lock held to submit I/O after enqueuing a new request */
Expand Down
10 changes: 5 additions & 5 deletions block/curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static gboolean curl_drop_socket(void *key, void *value, void *opaque)
CURLSocket *socket = value;
BDRVCURLState *s = socket->s;

aio_set_fd_handler(s->aio_context, socket->fd, false,
aio_set_fd_handler(s->aio_context, socket->fd,
NULL, NULL, NULL, NULL, NULL);
return true;
}
Expand Down Expand Up @@ -180,20 +180,20 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
trace_curl_sock_cb(action, (int)fd);
switch (action) {
case CURL_POLL_IN:
aio_set_fd_handler(s->aio_context, fd, false,
aio_set_fd_handler(s->aio_context, fd,
curl_multi_do, NULL, NULL, NULL, socket);
break;
case CURL_POLL_OUT:
aio_set_fd_handler(s->aio_context, fd, false,
aio_set_fd_handler(s->aio_context, fd,
NULL, curl_multi_do, NULL, NULL, socket);
break;
case CURL_POLL_INOUT:
aio_set_fd_handler(s->aio_context, fd, false,
aio_set_fd_handler(s->aio_context, fd,
curl_multi_do, curl_multi_do,
NULL, NULL, socket);
break;
case CURL_POLL_REMOVE:
aio_set_fd_handler(s->aio_context, fd, false,
aio_set_fd_handler(s->aio_context, fd,
NULL, NULL, NULL, NULL, NULL);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions block/export/fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void fuse_export_drained_begin(void *opaque)
FuseExport *exp = opaque;

aio_set_fd_handler(exp->common.ctx,
fuse_session_fd(exp->fuse_session), false,
fuse_session_fd(exp->fuse_session),
NULL, NULL, NULL, NULL, NULL);
exp->fd_handler_set_up = false;
}
Expand All @@ -97,7 +97,7 @@ static void fuse_export_drained_end(void *opaque)
exp->common.ctx = blk_get_aio_context(exp->common.blk);

aio_set_fd_handler(exp->common.ctx,
fuse_session_fd(exp->fuse_session), false,
fuse_session_fd(exp->fuse_session),
read_from_fuse_export, NULL, NULL, NULL, exp);
exp->fd_handler_set_up = true;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ static int setup_fuse_export(FuseExport *exp, const char *mountpoint,
g_hash_table_insert(exports, g_strdup(mountpoint), NULL);

aio_set_fd_handler(exp->common.ctx,
fuse_session_fd(exp->fuse_session), false,
fuse_session_fd(exp->fuse_session),
read_from_fuse_export, NULL, NULL, NULL, exp);
exp->fd_handler_set_up = true;

Expand Down Expand Up @@ -320,7 +320,7 @@ static void fuse_export_shutdown(BlockExport *blk_exp)

if (exp->fd_handler_set_up) {
aio_set_fd_handler(exp->common.ctx,
fuse_session_fd(exp->fuse_session), false,
fuse_session_fd(exp->fuse_session),
NULL, NULL, NULL, NULL, NULL);
exp->fd_handler_set_up = false;
}
Expand Down
10 changes: 5 additions & 5 deletions block/export/vduse-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void vduse_blk_enable_queue(VduseDev *dev, VduseVirtq *vq)
}

aio_set_fd_handler(vblk_exp->export.ctx, vduse_queue_get_fd(vq),
false, on_vduse_vq_kick, NULL, NULL, NULL, vq);
on_vduse_vq_kick, NULL, NULL, NULL, vq);
/* Make sure we don't miss any kick afer reconnecting */
eventfd_write(vduse_queue_get_fd(vq), 1);
}
Expand All @@ -151,7 +151,7 @@ static void vduse_blk_disable_queue(VduseDev *dev, VduseVirtq *vq)
return;
}

aio_set_fd_handler(vblk_exp->export.ctx, fd, false,
aio_set_fd_handler(vblk_exp->export.ctx, fd,
NULL, NULL, NULL, NULL, NULL);
}

Expand All @@ -170,7 +170,7 @@ static void on_vduse_dev_kick(void *opaque)
static void vduse_blk_attach_ctx(VduseBlkExport *vblk_exp, AioContext *ctx)
{
aio_set_fd_handler(vblk_exp->export.ctx, vduse_dev_get_fd(vblk_exp->dev),
false, on_vduse_dev_kick, NULL, NULL, NULL,
on_vduse_dev_kick, NULL, NULL, NULL,
vblk_exp->dev);

/* Virtqueues are handled by vduse_blk_drained_end() */
Expand All @@ -179,7 +179,7 @@ static void vduse_blk_attach_ctx(VduseBlkExport *vblk_exp, AioContext *ctx)
static void vduse_blk_detach_ctx(VduseBlkExport *vblk_exp)
{
aio_set_fd_handler(vblk_exp->export.ctx, vduse_dev_get_fd(vblk_exp->dev),
false, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL);

/* Virtqueues are handled by vduse_blk_drained_begin() */
}
Expand Down Expand Up @@ -364,7 +364,7 @@ static int vduse_blk_exp_create(BlockExport *exp, BlockExportOptions *opts,
vduse_dev_setup_queue(vblk_exp->dev, i, queue_size);
}

aio_set_fd_handler(exp->ctx, vduse_dev_get_fd(vblk_exp->dev), false,
aio_set_fd_handler(exp->ctx, vduse_dev_get_fd(vblk_exp->dev),
on_vduse_dev_kick, NULL, NULL, NULL, vblk_exp->dev);

blk_add_aio_context_notifier(exp->blk, blk_aio_attached, blk_aio_detach,
Expand Down
2 changes: 0 additions & 2 deletions block/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,

/* Stop things in parent-to-child order */
if (qatomic_fetch_inc(&bs->quiesce_counter) == 0) {
aio_disable_external(bdrv_get_aio_context(bs));
bdrv_parent_drained_begin(bs, parent);
if (bs->drv && bs->drv->bdrv_drain_begin) {
bs->drv->bdrv_drain_begin(bs);
Expand Down Expand Up @@ -418,7 +417,6 @@ static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent)
bs->drv->bdrv_drain_end(bs);
}
bdrv_parent_drained_end(bs, parent);
aio_enable_external(bdrv_get_aio_context(bs));
}
}

Expand Down
4 changes: 2 additions & 2 deletions block/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ int coroutine_fn luring_co_submit(BlockDriverState *bs, int fd, uint64_t offset,

void luring_detach_aio_context(LuringState *s, AioContext *old_context)
{
aio_set_fd_handler(old_context, s->ring.ring_fd, false,
aio_set_fd_handler(old_context, s->ring.ring_fd,
NULL, NULL, NULL, NULL, s);
qemu_bh_delete(s->completion_bh);
s->aio_context = NULL;
Expand All @@ -420,7 +420,7 @@ void luring_attach_aio_context(LuringState *s, AioContext *new_context)
{
s->aio_context = new_context;
s->completion_bh = aio_bh_new(new_context, qemu_luring_completion_bh, s);
aio_set_fd_handler(s->aio_context, s->ring.ring_fd, false,
aio_set_fd_handler(s->aio_context, s->ring.ring_fd,
qemu_luring_completion_cb, NULL,
qemu_luring_poll_cb, qemu_luring_poll_ready, s);
}
Expand Down
3 changes: 1 addition & 2 deletions block/iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ iscsi_set_events(IscsiLun *iscsilun)

if (ev != iscsilun->events) {
aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsi),
false,
(ev & POLLIN) ? iscsi_process_read : NULL,
(ev & POLLOUT) ? iscsi_process_write : NULL,
NULL, NULL,
Expand Down Expand Up @@ -1540,7 +1539,7 @@ static void iscsi_detach_aio_context(BlockDriverState *bs)
IscsiLun *iscsilun = bs->opaque;

aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsilun->iscsi),
false, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL);
iscsilun->events = 0;

if (iscsilun->nop_timer) {
Expand Down
4 changes: 2 additions & 2 deletions block/linux-aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ int coroutine_fn laio_co_submit(int fd, uint64_t offset, QEMUIOVector *qiov,

void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)
{
aio_set_event_notifier(old_context, &s->e, false, NULL, NULL, NULL);
aio_set_event_notifier(old_context, &s->e, NULL, NULL, NULL);
qemu_bh_delete(s->completion_bh);
s->aio_context = NULL;
}
Expand All @@ -455,7 +455,7 @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
{
s->aio_context = new_context;
s->completion_bh = aio_bh_new(new_context, qemu_laio_completion_bh, s);
aio_set_event_notifier(new_context, &s->e, false,
aio_set_event_notifier(new_context, &s->e,
qemu_laio_completion_cb,
qemu_laio_poll_cb,
qemu_laio_poll_ready);
Expand Down
5 changes: 2 additions & 3 deletions block/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ static void nfs_set_events(NFSClient *client)
int ev = nfs_which_events(client->context);
if (ev != client->events) {
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
false,
(ev & POLLIN) ? nfs_process_read : NULL,
(ev & POLLOUT) ? nfs_process_write : NULL,
NULL, NULL, client);
Expand Down Expand Up @@ -373,7 +372,7 @@ static void nfs_detach_aio_context(BlockDriverState *bs)
NFSClient *client = bs->opaque;

aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
false, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL);
client->events = 0;
}

Expand All @@ -391,7 +390,7 @@ static void nfs_client_close(NFSClient *client)
if (client->context) {
qemu_mutex_lock(&client->mutex);
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
false, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL, NULL, NULL);
qemu_mutex_unlock(&client->mutex);
if (client->fh) {
nfs_close(client->context, client->fh);
Expand Down
8 changes: 4 additions & 4 deletions block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
}
aio_set_event_notifier(bdrv_get_aio_context(bs),
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, nvme_handle_event, nvme_poll_cb,
nvme_handle_event, nvme_poll_cb,
nvme_poll_ready);

if (!nvme_identify(bs, namespace, errp)) {
Expand Down Expand Up @@ -948,7 +948,7 @@ static void nvme_close(BlockDriverState *bs)
g_free(s->queues);
aio_set_event_notifier(bdrv_get_aio_context(bs),
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, NULL, NULL, NULL);
NULL, NULL, NULL);
event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]);
qemu_vfio_pci_unmap_bar(s->vfio, 0, s->bar0_wo_map,
0, sizeof(NvmeBar) + NVME_DOORBELL_SIZE);
Expand Down Expand Up @@ -1546,7 +1546,7 @@ static void nvme_detach_aio_context(BlockDriverState *bs)

aio_set_event_notifier(bdrv_get_aio_context(bs),
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, NULL, NULL, NULL);
NULL, NULL, NULL);
}

static void nvme_attach_aio_context(BlockDriverState *bs,
Expand All @@ -1556,7 +1556,7 @@ static void nvme_attach_aio_context(BlockDriverState *bs,

s->aio_context = new_context;
aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
false, nvme_handle_event, nvme_poll_cb,
nvme_handle_event, nvme_poll_cb,
nvme_poll_ready);

for (unsigned i = 0; i < s->queue_count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions block/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ static void restart_coroutine(void *opaque)
AioContext *ctx = bdrv_get_aio_context(bs);

trace_ssh_restart_coroutine(restart->co);
aio_set_fd_handler(ctx, s->sock, false, NULL, NULL, NULL, NULL, NULL);
aio_set_fd_handler(ctx, s->sock, NULL, NULL, NULL, NULL, NULL);

aio_co_wake(restart->co);
}
Expand Down Expand Up @@ -1049,7 +1049,7 @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs)
trace_ssh_co_yield(s->sock, rd_handler, wr_handler);

aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock,
false, rd_handler, wr_handler, NULL, NULL, &restart);
rd_handler, wr_handler, NULL, NULL, &restart);
qemu_coroutine_yield();
trace_ssh_co_yield_back(s->sock);
}
Expand Down
6 changes: 3 additions & 3 deletions block/win32-aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ int win32_aio_attach(QEMUWin32AIOState *aio, HANDLE hfile)
void win32_aio_detach_aio_context(QEMUWin32AIOState *aio,
AioContext *old_context)
{
aio_set_event_notifier(old_context, &aio->e, false, NULL, NULL, NULL);
aio_set_event_notifier(old_context, &aio->e, NULL, NULL, NULL);
aio->aio_ctx = NULL;
}

void win32_aio_attach_aio_context(QEMUWin32AIOState *aio,
AioContext *new_context)
{
aio->aio_ctx = new_context;
aio_set_event_notifier(new_context, &aio->e, false,
win32_aio_completion_cb, NULL, NULL);
aio_set_event_notifier(new_context, &aio->e, win32_aio_completion_cb,
NULL, NULL);
}

QEMUWin32AIOState *win32_aio_init(void)
Expand Down
2 changes: 1 addition & 1 deletion hw/i386/kvm/xen_xenstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void xen_xenstore_realize(DeviceState *dev, Error **errp)
error_setg(errp, "Xenstore evtchn port init failed");
return;
}
aio_set_fd_handler(qemu_get_aio_context(), xen_be_evtchn_fd(s->eh), false,
aio_set_fd_handler(qemu_get_aio_context(), xen_be_evtchn_fd(s->eh),
xen_xenstore_event, NULL, NULL, NULL, s);

s->impl = xs_impl_create(xen_domid);
Expand Down
6 changes: 3 additions & 3 deletions hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,7 @@ static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n)

void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
{
aio_set_event_notifier(ctx, &vq->host_notifier, false,
aio_set_event_notifier(ctx, &vq->host_notifier,
virtio_queue_host_notifier_read,
virtio_queue_host_notifier_aio_poll,
virtio_queue_host_notifier_aio_poll_ready);
Expand All @@ -3508,14 +3508,14 @@ void virtio_queue_aio_attach_host_notifier(VirtQueue *vq, AioContext *ctx)
*/
void virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ctx)
{
aio_set_event_notifier(ctx, &vq->host_notifier, false,
aio_set_event_notifier(ctx, &vq->host_notifier,
virtio_queue_host_notifier_read,
NULL, NULL);
}

void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx)
{
aio_set_event_notifier(ctx, &vq->host_notifier, false, NULL, NULL, NULL);
aio_set_event_notifier(ctx, &vq->host_notifier, NULL, NULL, NULL);
}

void virtio_queue_host_notifier_read(EventNotifier *n)
Expand Down
8 changes: 4 additions & 4 deletions hw/xen/xen-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,14 @@ void xen_device_set_event_channel_context(XenDevice *xendev,
}

if (channel->ctx)
aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh), false,
aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh),
NULL, NULL, NULL, NULL, NULL);

channel->ctx = ctx;
if (ctx) {
aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh),
false, xen_device_event, NULL, xen_device_poll,
NULL, channel);
xen_device_event, NULL, xen_device_poll, NULL,
channel);
}
}

Expand Down Expand Up @@ -923,7 +923,7 @@ void xen_device_unbind_event_channel(XenDevice *xendev,

QLIST_REMOVE(channel, list);

aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh), false,
aio_set_fd_handler(channel->ctx, qemu_xen_evtchn_fd(channel->xeh),
NULL, NULL, NULL, NULL, NULL);

if (qemu_xen_evtchn_unbind(channel->xeh, channel->local_port) < 0) {
Expand Down
Loading

0 comments on commit 60f782b

Please sign in to comment.