From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV8dy-0004vm-Nc for qemu-devel@nongnu.org; Wed, 03 Aug 2016 22:44:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bV8dv-0005Ol-KV for qemu-devel@nongnu.org; Wed, 03 Aug 2016 22:44:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV8dv-0005OC-Ec for qemu-devel@nongnu.org; Wed, 03 Aug 2016 22:44:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E71F285A07 for ; Thu, 4 Aug 2016 02:44:18 +0000 (UTC) From: Fam Zheng Date: Thu, 4 Aug 2016 10:44:13 +0800 Message-Id: <1470278654-13525-2-git-send-email-famz@redhat.com> In-Reply-To: <1470278654-13525-1-git-send-email-famz@redhat.com> References: <1470278654-13525-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v3 1/2] virtio-blk: Release s->rq queue at system_reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, lersek@redhat.com, stefanha@redhat.com At system_reset, there is no point in retrying the queued request, because the driver that issued the request won't be around any more. Analyzed-by: Laszlo Ersek Reported-by: Laszlo Ersek Signed-off-by: Fam Zheng Reviewed-by: Laszlo Ersek --- hw/block/virtio-blk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 475a822..1e348b1 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -654,6 +654,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); AioContext *ctx; + VirtIOBlockReq *req; /* * This should cancel pending requests, but can't do nicely until there @@ -663,6 +664,14 @@ static void virtio_blk_reset(VirtIODevice *vdev) aio_context_acquire(ctx); blk_drain(s->blk); + /* We drop queued requests after blk_drain() because blk_drain() itself can + * produce them. */ + while (s->rq) { + req = s->rq; + s->rq = req->next; + virtio_blk_free_request(req); + } + if (s->dataplane) { virtio_blk_data_plane_stop(s->dataplane); } -- 2.7.4