From patchwork Fri Mar 15 15:14:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 228059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 16F0D2C0667 for ; Sat, 16 Mar 2013 02:23:43 +1100 (EST) Received: from localhost ([::1]:35272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGWTt-0003Zm-7A for incoming@patchwork.ozlabs.org; Fri, 15 Mar 2013 11:23:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGWLr-0000TU-Ok for qemu-devel@nongnu.org; Fri, 15 Mar 2013 11:15:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGWLl-0004XT-77 for qemu-devel@nongnu.org; Fri, 15 Mar 2013 11:15:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGWLk-0004XO-V5 for qemu-devel@nongnu.org; Fri, 15 Mar 2013 11:15:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2FFFGCB001256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Mar 2013 11:15:16 -0400 Received: from localhost (ovpn-112-50.ams2.redhat.com [10.36.112.50]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2FFFFHW000559; Fri, 15 Mar 2013 11:15:15 -0400 From: Stefan Hajnoczi To: Date: Fri, 15 Mar 2013 16:14:22 +0100 Message-Id: <1363360465-5247-26-git-send-email-stefanha@redhat.com> In-Reply-To: <1363360465-5247-1-git-send-email-stefanha@redhat.com> References: <1363360465-5247-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH 25/28] dataplane: fix hang introduced by AioContext transition X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini The bug is that the EventNotifiers do have a NULL io_flush callback. Because _none_ of the callbacks on the dataplane AioContext have such a callback, aio_poll will simply do nothing. Fixed by adding the callbacks: the ioeventfd will always be polled (this can change in the future to pause/resume the processing during live snapshots or similar operations); the ioqueue will be polled if there are outstanding requests. I must admit I have screwed up my testing somehow, because commit 2c20e71 does not work even if cherry-picked on top of 1.4.0, and this patch fixes it there as well. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- hw/dataplane/virtio-blk.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/dataplane/virtio-blk.c b/hw/dataplane/virtio-blk.c index dfe5f9b..1242d61 100644 --- a/hw/dataplane/virtio-blk.c +++ b/hw/dataplane/virtio-blk.c @@ -263,6 +263,11 @@ static int process_request(IOQueue *ioq, struct iovec iov[], } } +static int flush_true(EventNotifier *e) +{ + return true; +} + static void handle_notify(EventNotifier *e) { VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, @@ -342,6 +347,14 @@ static void handle_notify(EventNotifier *e) } } +static int flush_io(EventNotifier *e) +{ + VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, + io_notifier); + + return s->num_reqs > 0; +} + static void handle_io(EventNotifier *e) { VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane, @@ -472,7 +485,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) exit(1); } s->host_notifier = *virtio_queue_get_host_notifier(vq); - aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify, NULL); + aio_set_event_notifier(s->ctx, &s->host_notifier, handle_notify, flush_true); /* Set up ioqueue */ ioq_init(&s->ioqueue, s->fd, REQ_MAX); @@ -480,7 +493,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) ioq_put_iocb(&s->ioqueue, &s->requests[i].iocb); } s->io_notifier = *ioq_get_notifier(&s->ioqueue); - aio_set_event_notifier(s->ctx, &s->io_notifier, handle_io, NULL); + aio_set_event_notifier(s->ctx, &s->io_notifier, handle_io, flush_io); s->started = true; trace_virtio_blk_data_plane_start(s);