async: Introduce aio_co_enter
authorFam Zheng <famz@redhat.com>
Mon, 10 Apr 2017 12:07:35 +0000 (20:07 +0800)
committerFam Zheng <famz@redhat.com>
Tue, 11 Apr 2017 12:07:15 +0000 (20:07 +0800)
They start the coroutine on the specified context.

Signed-off-by: Fam Zheng <famz@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
include/block/aio.h
util/async.c

index 677b6ffc2596ad6b85a4f35227df4a4d2b2e545d..406e32305a9d676b09922a351530ad63c3e8b624 100644 (file)
@@ -510,6 +510,15 @@ void aio_co_schedule(AioContext *ctx, struct Coroutine *co);
  */
 void aio_co_wake(struct Coroutine *co);
 
+/**
+ * aio_co_enter:
+ * @ctx: the context to run the coroutine
+ * @co: the coroutine to run
+ *
+ * Enter a coroutine in the specified AioContext.
+ */
+void aio_co_enter(AioContext *ctx, struct Coroutine *co);
+
 /**
  * Return the AioContext whose event loop runs in the current thread.
  *
index 663e297e1f590375942d897c67fc2c94569b98ea..355af73ee71b078215e18552fbdcd0ee8c325370 100644 (file)
@@ -453,6 +453,11 @@ void aio_co_wake(struct Coroutine *co)
     smp_read_barrier_depends();
     ctx = atomic_read(&co->ctx);
 
+    aio_co_enter(ctx, co);
+}
+
+void aio_co_enter(AioContext *ctx, struct Coroutine *co)
+{
     if (ctx != qemu_get_current_aio_context()) {
         aio_co_schedule(ctx, co);
         return;
@@ -464,7 +469,7 @@ void aio_co_wake(struct Coroutine *co)
         QSIMPLEQ_INSERT_TAIL(&self->co_queue_wakeup, co, co_queue_next);
     } else {
         aio_context_acquire(ctx);
-        qemu_coroutine_enter(co);
+        qemu_aio_coroutine_enter(ctx, co);
         aio_context_release(ctx);
     }
 }