* [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
@ 2016-07-29 10:22 Fam Zheng
2016-07-29 10:41 ` Laszlo Ersek
2016-08-02 6:46 ` Paolo Bonzini
0 siblings, 2 replies; 6+ messages in thread
From: Fam Zheng @ 2016-07-29 10:22 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha, lersek
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 <lersek@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
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);
if (s->dataplane) {
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
2016-07-29 10:22 [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset Fam Zheng
@ 2016-07-29 10:41 ` Laszlo Ersek
2016-08-01 2:54 ` Fam Zheng
2016-08-02 6:46 ` Paolo Bonzini
1 sibling, 1 reply; 6+ messages in thread
From: Laszlo Ersek @ 2016-07-29 10:41 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: stefanha
Fam,
On 07/29/16 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 <lersek@redhat.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> 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);
>
> if (s->dataplane) {
>
The comment
/*
* This should cancel pending requests, but can't do nicely until there
* are per-device request lists.
*/
dates back to
commit 6e02c38dadfe4cf02b0da6135adfd8d9352b90e1
Author: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Date: Thu Dec 4 19:52:44 2008 +0000
Add virtio-blk support
Virtio-blk is a paravirtual block device based on VirtIO. It can be used by
specifying the if=virtio parameter to the -drive parameter.
When using -enable-kvm, it can achieve very good performance compared to IDE or
SCSI.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5870 c046a42c-6fe2-441c-8c8c-71466251a162
I think the comment is obsolete now, the idea that it expresses was actually fixed in the following commit, in my opinion:
commit 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a
Author: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Date: Wed Jun 17 13:37:20 2015 +0300
virtio-blk: Use blk_drain() to drain IO requests
Each call of the virtio_blk_reset() function calls blk_drain_all(),
which works for all existing BlockDriverStates, while draining only
one is needed.
This patch replaces blk_drain_all() by blk_drain() in
virtio_blk_reset(). virtio_blk_data_plane_stop() should be called
after draining because it restores vblk->complete_request.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Message-id: 1434537440-28236-3-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
So how about turning this patch into a two part series: the first patch should drop the comment, and reference 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a, while the second patch should be this patch?
For this patch:
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
I definitely recommend that Stefan review this patch too.
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
2016-07-29 10:41 ` Laszlo Ersek
@ 2016-08-01 2:54 ` Fam Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Fam Zheng @ 2016-08-01 2:54 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: qemu-devel, stefanha
On Fri, 07/29 12:41, Laszlo Ersek wrote:
> So how about turning this patch into a two part series: the first patch
> should drop the comment, and reference
> 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a, while the second patch should be
> this patch?
Good idea, I'm sending a separate patch to remove the comment.
Fam
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
2016-07-29 10:22 [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset Fam Zheng
2016-07-29 10:41 ` Laszlo Ersek
@ 2016-08-02 6:46 ` Paolo Bonzini
2016-08-02 7:24 ` Fam Zheng
1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-08-02 6:46 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: lersek, stefanha
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 <lersek@redhat.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> 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) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
2016-08-02 6:46 ` Paolo Bonzini
@ 2016-08-02 7:24 ` Fam Zheng
2016-08-02 7:29 ` Fam Zheng
0 siblings, 1 reply; 6+ messages in thread
From: Fam Zheng @ 2016-08-02 7:24 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, lersek, stefanha
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 <lersek@redhat.com>
> > Reported-by: Laszlo Ersek <lersek@redhat.com>
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> > 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.
Fam
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset
2016-08-02 7:24 ` Fam Zheng
@ 2016-08-02 7:29 ` Fam Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Fam Zheng @ 2016-08-02 7:29 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, lersek, stefanha
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 <lersek@redhat.com>
> > > Reported-by: Laszlo Ersek <lersek@redhat.com>
> > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > ---
> > > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-02 7:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-29 10:22 [Qemu-devel] [PATCH] virtio-blk: Release s->rq queue at system_reset Fam Zheng
2016-07-29 10:41 ` Laszlo Ersek
2016-08-01 2:54 ` Fam Zheng
2016-08-02 6:46 ` Paolo Bonzini
2016-08-02 7:24 ` Fam Zheng
2016-08-02 7:29 ` Fam Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).