On Wed, Dec 13, 2023 at 10:15 PM Stefan Hajnoczi <stefa...@redhat.com> wrote: > - /* If a read is in progress, just mark the node as deleted */ > - if (ctx->walking_handlers > 0) { > - QLIST_INSERT_HEAD_RCU(&ctx->deleted_aio_handlers, node, > node_deleted); > - return false; > + /* If polling was started on the node then end it now */ > + if (ctx->poll_started && node->io_poll_end) { > + node->io_poll_end(node->opaque); > + > + /* Poll one last time in case ->io_poll_end() raced with the event */ > + if (node->io_poll(node->opaque)) { > + poll_ready = true; > + }
Do you need this at all? If the caller is removing the handlers, they should have put themselves in a state where they don't care about the file descriptor becoming readable. You still have to be careful because aio_bh_schedule_oneshot() can trigger remote nested event loops (which can cause deadlocks and, I am especially afraid, can take some time and invalidate the expectation that you don't need to drop the BQL). But it does simplify this patch quite a bit. Paolo