From 5030396f715194896347881daf1fb2a27effd12e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 21 Mar 2025 20:47:17 +0300 Subject: [PATCH] Clear QEMU eventfd handler on vitastor block driver destruction --- src/client/qemu_driver.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/client/qemu_driver.c b/src/client/qemu_driver.c index 4c5f3633..f9ddbba2 100644 --- a/src/client/qemu_driver.c +++ b/src/client/qemu_driver.c @@ -568,6 +568,22 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E static void vitastor_close(BlockDriverState *bs) { VitastorClient *client = bs->opaque; + if (client->uring_eventfd >= 0) + { + // clear the eventfd handler + universal_aio_set_fd_handler(client->ctx, client->uring_eventfd, NULL, NULL, NULL); + int wait_bh = 0; + qemu_mutex_lock(&client->mutex); + // clear uring_eventfd itself to prevent future scheduling of new B/H + client->uring_eventfd = -1; + wait_bh = client->bh_uring_scheduled; + qemu_mutex_unlock(&client->mutex); + if (wait_bh) + { + // wait until existing scheduled B/H is ran + BDRV_POLL_WHILE(bs, client->bh_uring_scheduled); + } + } vitastor_c_destroy(client->proxy); if (client->fds) {