Patchwork [v6,03/18] dataplane/virtio-blk: check exit conditions before aio_poll()

login
register
mail settings
Submitter Stefan Hajnoczi
Date July 25, 2013, 3:18 p.m.
Message ID <1374765505-14356-4-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/261764/
State New
Headers show

Comments

Stefan Hajnoczi - July 25, 2013, 3:18 p.m.
Check exit conditions before entering blocking aio_poll().  This is
mainly for consistency since it's unlikely that we are stopping in the
first event loop iteration.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/dataplane/virtio-blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Jeff Cody - July 26, 2013, 4:44 p.m.
On Thu, Jul 25, 2013 at 05:18:10PM +0200, Stefan Hajnoczi wrote:
> Check exit conditions before entering blocking aio_poll().  This is
> mainly for consistency since it's unlikely that we are stopping in the
> first event loop iteration.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/block/dataplane/virtio-blk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
> index 2faed43..8d3e145 100644
> --- a/hw/block/dataplane/virtio-blk.c
> +++ b/hw/block/dataplane/virtio-blk.c
> @@ -379,9 +379,9 @@ static void *data_plane_thread(void *opaque)
>  {
>      VirtIOBlockDataPlane *s = opaque;
>  
> -    do {
> +    while (!s->stopping || s->num_reqs > 0) {
>          aio_poll(s->ctx, true);
> -    } while (!s->stopping || s->num_reqs > 0);
> +    }
>      return NULL;
>  }
>  
> -- 
> 1.8.1.4
> 
>

Reviewed-by: Jeff Cody <jcody@redhat.com>
Wayne Xia - July 29, 2013, 7:10 a.m.
> Check exit conditions before entering blocking aio_poll().  This is
> mainly for consistency since it's unlikely that we are stopping in the
> first event loop iteration.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   hw/block/dataplane/virtio-blk.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
> index 2faed43..8d3e145 100644
> --- a/hw/block/dataplane/virtio-blk.c
> +++ b/hw/block/dataplane/virtio-blk.c
> @@ -379,9 +379,9 @@ static void *data_plane_thread(void *opaque)
>   {
>       VirtIOBlockDataPlane *s = opaque;
> 
> -    do {
> +    while (!s->stopping || s->num_reqs > 0) {
>           aio_poll(s->ctx, true);
> -    } while (!s->stopping || s->num_reqs > 0);
> +    }
>       return NULL;
>   }
>
It seems more likely a bug fix.

Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

Patch

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 2faed43..8d3e145 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -379,9 +379,9 @@  static void *data_plane_thread(void *opaque)
 {
     VirtIOBlockDataPlane *s = opaque;
 
-    do {
+    while (!s->stopping || s->num_reqs > 0) {
         aio_poll(s->ctx, true);
-    } while (!s->stopping || s->num_reqs > 0);
+    }
     return NULL;
 }