diff mbox

mirror: Skip block_job_defer_to_main_loop if already in the main context

Message ID 1432866133-21111-1-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng May 29, 2015, 2:22 a.m. UTC
mirror_exit does the replacing, which requires source and target to be
in sync, unfortunately we can't guarantee that before we have a complete
block pause mechanism. So for non-dataplane block jobs, let's do the old
thing as pre commit 5a7e7a0ba (block: let mirror blockjob run in BDS
AioContext) - directly call mirror_exit().

Dataplane case is taken care of in separate patches.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/mirror.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stefan Hajnoczi May 29, 2015, 12:37 p.m. UTC | #1
On Fri, May 29, 2015 at 10:22:13AM +0800, Fam Zheng wrote:
> mirror_exit does the replacing, which requires source and target to be
> in sync, unfortunately we can't guarantee that before we have a complete
> block pause mechanism. So for non-dataplane block jobs, let's do the old
> thing as pre commit 5a7e7a0ba (block: let mirror blockjob run in BDS
> AioContext) - directly call mirror_exit().
> 
> Dataplane case is taken care of in separate patches.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/mirror.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Please CC Jeff Cody <jcody@redhat.com> on blockjob patches.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Fam Zheng June 1, 2015, 1:46 a.m. UTC | #2
On Fri, 05/29 13:37, Stefan Hajnoczi wrote:
> On Fri, May 29, 2015 at 10:22:13AM +0800, Fam Zheng wrote:
> > mirror_exit does the replacing, which requires source and target to be
> > in sync, unfortunately we can't guarantee that before we have a complete
> > block pause mechanism. So for non-dataplane block jobs, let's do the old
> > thing as pre commit 5a7e7a0ba (block: let mirror blockjob run in BDS
> > AioContext) - directly call mirror_exit().
> > 
> > Dataplane case is taken care of in separate patches.
> > 
> > Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  block/mirror.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> Please CC Jeff Cody <jcody@redhat.com> on blockjob patches.

Didn't I?

Fam
Stefan Hajnoczi June 1, 2015, 12:55 p.m. UTC | #3
On Mon, Jun 01, 2015 at 09:46:39AM +0800, Fam Zheng wrote:
> On Fri, 05/29 13:37, Stefan Hajnoczi wrote:
> > On Fri, May 29, 2015 at 10:22:13AM +0800, Fam Zheng wrote:
> > > mirror_exit does the replacing, which requires source and target to be
> > > in sync, unfortunately we can't guarantee that before we have a complete
> > > block pause mechanism. So for non-dataplane block jobs, let's do the old
> > > thing as pre commit 5a7e7a0ba (block: let mirror blockjob run in BDS
> > > AioContext) - directly call mirror_exit().
> > > 
> > > Dataplane case is taken care of in separate patches.
> > > 
> > > Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > ---
> > >  block/mirror.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > Please CC Jeff Cody <jcody@redhat.com> on blockjob patches.
> 
> Didn't I?

Oops, sorry I missed it.

Stefan
Fam Zheng June 8, 2015, 3:08 a.m. UTC | #4
On Fri, 05/29 10:22, Fam Zheng wrote:
> mirror_exit does the replacing, which requires source and target to be
> in sync, unfortunately we can't guarantee that before we have a complete
> block pause mechanism. So for non-dataplane block jobs, let's do the old
> thing as pre commit 5a7e7a0ba (block: let mirror blockjob run in BDS
> AioContext) - directly call mirror_exit().
> 
> Dataplane case is taken care of in separate patches.

This one is superceded by

[PATCH v2 07/13] mirror: Protect source between bdrv_drain and bdrv_swap

Fam

> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/mirror.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index 58f391a..112393a 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -565,7 +565,11 @@ immediate_exit:
>  
>      data = g_malloc(sizeof(*data));
>      data->ret = ret;
> -    block_job_defer_to_main_loop(&s->common, mirror_exit, data);
> +    if (bs->aio_context == qemu_get_aio_context()) {
> +        mirror_exit(&s->common, data);
> +    } else {
> +        block_job_defer_to_main_loop(&s->common, mirror_exit, data);
> +    }
>  }
>  
>  static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp)
> -- 
> 2.4.2
> 
>
diff mbox

Patch

diff --git a/block/mirror.c b/block/mirror.c
index 58f391a..112393a 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -565,7 +565,11 @@  immediate_exit:
 
     data = g_malloc(sizeof(*data));
     data->ret = ret;
-    block_job_defer_to_main_loop(&s->common, mirror_exit, data);
+    if (bs->aio_context == qemu_get_aio_context()) {
+        mirror_exit(&s->common, data);
+    } else {
+        block_job_defer_to_main_loop(&s->common, mirror_exit, data);
+    }
 }
 
 static void mirror_set_speed(BlockJob *job, int64_t speed, Error **errp)