qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] Two virtio-blk fixes
@ 2016-08-02 13:00 Fam Zheng
  2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset Fam Zheng
  2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 2/2] virtio-blk: Remove stale comment about draining Fam Zheng
  0 siblings, 2 replies; 7+ messages in thread
From: Fam Zheng @ 2016-08-02 13:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, lersek, pbonzini

v2: Patch 1: address Paolo's comment to move the dropping code to below
    blk_drain().
    Patch 2: add Laszlo's r-b.

Fam Zheng (2):
  virtio-blk: Release s->rq queue at system_reset
  virtio-blk: Remove stale comment about draining

 hw/block/virtio-blk.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset
  2016-08-02 13:00 [Qemu-devel] [PATCH v2 0/2] Two virtio-blk fixes Fam Zheng
@ 2016-08-02 13:00 ` Fam Zheng
  2016-08-02 13:31   ` Laszlo Ersek
  2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 2/2] virtio-blk: Remove stale comment about draining Fam Zheng
  1 sibling, 1 reply; 7+ messages in thread
From: Fam Zheng @ 2016-08-02 13:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, lersek, pbonzini

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..12587d9 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
@@ -662,6 +663,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)
     ctx = blk_get_aio_context(s->blk);
     aio_context_acquire(ctx);
     blk_drain(s->blk);
+    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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] virtio-blk: Remove stale comment about draining
  2016-08-02 13:00 [Qemu-devel] [PATCH v2 0/2] Two virtio-blk fixes Fam Zheng
  2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset Fam Zheng
@ 2016-08-02 13:00 ` Fam Zheng
  1 sibling, 0 replies; 7+ messages in thread
From: Fam Zheng @ 2016-08-02 13:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, lersek, pbonzini

This is stale after commit 6e40b3bf (virtio-blk: Use blk_drain() to
drain IO requests), remove it.

Suggested-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/block/virtio-blk.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 12587d9..948e8b5 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -656,10 +656,6 @@ static void virtio_blk_reset(VirtIODevice *vdev)
     AioContext *ctx;
     VirtIOBlockReq *req;
 
-    /*
-     * This should cancel pending requests, but can't do nicely until there
-     * are per-device request lists.
-     */
     ctx = blk_get_aio_context(s->blk);
     aio_context_acquire(ctx);
     blk_drain(s->blk);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset
  2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset Fam Zheng
@ 2016-08-02 13:31   ` Laszlo Ersek
  2016-08-02 17:00     ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Laszlo Ersek @ 2016-08-02 13:31 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel; +Cc: stefanha, pbonzini

On 08/02/16 15:00, 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..12587d9 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
> @@ -662,6 +663,11 @@ static void virtio_blk_reset(VirtIODevice *vdev)
>      ctx = blk_get_aio_context(s->blk);
>      aio_context_acquire(ctx);
>      blk_drain(s->blk);
> +    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);
> 

I'd prefer if Paolo's remark (about blk_drain()'s ability to produce
more failed requests, stashed in s->rq) were captured in either the
commit message, or in a code comment. Something like:

  /* We drop queued requests after blk_drain() because blk_drain()
   * itself can produce them. */

What do you think? It's your call. I certainly lacked that bit of
information.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset
  2016-08-02 13:31   ` Laszlo Ersek
@ 2016-08-02 17:00     ` Paolo Bonzini
  2016-08-03  0:52       ` Fam Zheng
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2016-08-02 17:00 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: Fam Zheng, qemu-devel, stefanha


> I'd prefer if Paolo's remark (about blk_drain()'s ability to produce
> more failed requests, stashed in s->rq) were captured in either the
> commit message, or in a code comment. Something like:
> 
>   /* We drop queued requests after blk_drain() because blk_drain()
>    * itself can produce them. */

It's also (perhaps especially) because blk_drain() can consume them.  Fam's
patch to do blk_drain() first would cause a double-free.

Paolo

> What do you think? It's your call. I certainly lacked that bit of
> information.
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks!
> Laszlo
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset
  2016-08-02 17:00     ` Paolo Bonzini
@ 2016-08-03  0:52       ` Fam Zheng
  2016-08-04 12:42         ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Fam Zheng @ 2016-08-03  0:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Laszlo Ersek, qemu-devel, stefanha

On Tue, 08/02 13:00, Paolo Bonzini wrote:
> 
> > I'd prefer if Paolo's remark (about blk_drain()'s ability to produce
> > more failed requests, stashed in s->rq) were captured in either the
> > commit message, or in a code comment. Something like:
> > 
> >   /* We drop queued requests after blk_drain() because blk_drain()
> >    * itself can produce them. */
> 
> It's also (perhaps especially) because blk_drain() can consume them.  Fam's
> patch to do blk_drain() first would cause a double-free.

That "consume" part is what I don't understand.

Shouldn't blk_drain() only process submitted requests (and further requests
they dequeue indirectly), while s->rq only contains failed requests. They don't
look overlap, because I suppose failed requests are only going to be processed
by run state change.

What am I missing?

Fam

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset
  2016-08-03  0:52       ` Fam Zheng
@ 2016-08-04 12:42         ` Paolo Bonzini
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2016-08-04 12:42 UTC (permalink / raw)
  To: Fam Zheng; +Cc: Laszlo Ersek, qemu-devel, stefanha



On 03/08/2016 02:52, Fam Zheng wrote:
>> > It's also (perhaps especially) because blk_drain() can consume them.  Fam's
>> > patch to do blk_drain() first would cause a double-free.
> That "consume" part is what I don't understand.
> 
> Shouldn't blk_drain() only process submitted requests (and further requests
> they dequeue indirectly), while s->rq only contains failed requests.

Nevermind, I was confused.  virtio_blk_init_request doesn't store the
requests in a list, unlike SCSI.

Paolo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-08-04 12:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 13:00 [Qemu-devel] [PATCH v2 0/2] Two virtio-blk fixes Fam Zheng
2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 1/2] virtio-blk: Release s->rq queue at system_reset Fam Zheng
2016-08-02 13:31   ` Laszlo Ersek
2016-08-02 17:00     ` Paolo Bonzini
2016-08-03  0:52       ` Fam Zheng
2016-08-04 12:42         ` Paolo Bonzini
2016-08-02 13:00 ` [Qemu-devel] [PATCH v2 2/2] virtio-blk: Remove stale comment about draining 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).