Received: from eggs.gnu.org ([2001:4830:134:3::10]:43059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUTTJ-0002CF-LE for qemu-devel@nongnu.org; Tue, 02 Aug 2016 02:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUTTD-0001YY-Lx for qemu-devel@nongnu.org; Tue, 02 Aug 2016 02:46:36 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUTTD-0001YT-Ew for qemu-devel@nongnu.org; Tue, 02 Aug 2016 02:46:31 -0400 Received: by mail-wm0-x244.google.com with SMTP id q128so29171896wma.1 for ; Mon, 01 Aug 2016 23:46:31 -0700 (PDT) Sender: Paolo Bonzini References: <1469787777-10688-1-git-send-email-famz@redhat.com> From: Paolo Bonzini Message-ID: <48043f1c-6509-682b-b098-0f10d92e9581@redhat.com> Date: Tue, 2 Aug 2016 08:46:27 +0200 MIME-Version: 1.0 In-Reply-To: <1469787777-10688-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: lersek@redhat.com, stefanha@redhat.com On 29/07/2016 12:22, Fam Zheng wrote: > 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 > --- > hw/block/virtio-blk.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index 475a822..89eca65 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 > @@ -661,6 +662,11 @@ static void virtio_blk_reset(VirtIODevice *vdev) > */ > ctx = blk_get_aio_context(s->blk); > aio_context_acquire(ctx); > + while (s->rq) { > + req = s->rq; > + s->rq = req->next; > + virtio_blk_free_request(req); > + } > blk_drain(s->blk); blk_drain can consume requests too, so I think it should be the other way round: first drain, then drop any failed request that's been left in s->rq. Paolo > if (s->dataplane) { >