Received: from eggs.gnu.org ([2001:4830:134:3::10]:48673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUU8U-0006Aa-VH for qemu-devel@nongnu.org; Tue, 02 Aug 2016 03:29:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUU8O-0007Az-3a for qemu-devel@nongnu.org; Tue, 02 Aug 2016 03:29:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUU8N-0007Ar-UF for qemu-devel@nongnu.org; Tue, 02 Aug 2016 03:29:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 8D6EAC04B312 for ; Tue, 2 Aug 2016 07:29:03 +0000 (UTC) Date: Tue, 2 Aug 2016 15:29:02 +0800 From: Fam Zheng Message-ID: <20160802072902.GB2095@ad.usersys.redhat.com> References: <1469787777-10688-1-git-send-email-famz@redhat.com> <48043f1c-6509-682b-b098-0f10d92e9581@redhat.com> <20160802072422.GA2095@ad.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160802072422.GA2095@ad.usersys.redhat.com> 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: Paolo Bonzini Cc: qemu-devel@nongnu.org, lersek@redhat.com, stefanha@redhat.com On Tue, 08/02 15:24, Fam Zheng wrote: > On Tue, 08/02 08:46, Paolo Bonzini wrote: > > > > > > 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. > > I don't think there is any difference in this, blk_drain cannot trigger > virtio_blk_dma_restart_cb, because it is only hooked to vm state change. Oh you mean that blk_drain can queue more requests to s->rq. That is a good point, indeed. Fam