[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 12/15] Make bdrv_flush coroutine only and add bdrv_
From: |
Charlie Shepherd |
Subject: |
[Qemu-devel] [RFC v2 12/15] Make bdrv_flush coroutine only and add bdrv_sync_flush |
Date: |
Fri, 9 Aug 2013 19:44:02 +0200 |
This patch renames the coroutine only bdrv_co_flush to bdrv_flush and the
original bdrv_flush to bdrv_sync_flush. bdrv_sync_flush is synchronous only.
This patch also converts a caller in block/mirror.c to coroutine_fn.
Signed-off-by: Charlie Shepherd <address@hidden>
---
block.c | 12 +++---------
block/mirror.c | 4 ++--
include/block/block.h | 4 ++--
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/block.c b/block.c
index 6995d3f..27339af 100644
--- a/block.c
+++ b/block.c
@@ -4078,7 +4078,7 @@ static void coroutine_fn bdrv_flush_co_entry(void *opaque)
rwco->ret = bdrv_co_flush(rwco->bs);
}
-int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
+int coroutine_fn bdrv_flush(BlockDriverState *bs)
{
int ret;
@@ -4166,7 +4166,7 @@ void bdrv_clear_incoming_migration_all(void)
}
}
-int bdrv_flush(BlockDriverState *bs)
+int bdrv_sync_flush(BlockDriverState *bs)
{
Coroutine *co;
RwCo rwco = {
@@ -4174,13 +4174,7 @@ int bdrv_flush(BlockDriverState *bs)
.ret = NOT_DONE,
};
- if (qemu_in_coroutine()) {
- /* Fast-path if already in coroutine context */
- bdrv_flush_co_entry(&rwco);
- return rwco.ret;
- } else {
- return bdrv_sync_rwco(bdrv_flush_co_entry, &rwco);
- }
+ return bdrv_sync_rwco(bdrv_flush_co_entry, &rwco);
}
static void coroutine_fn bdrv_discard_co_entry(void *opaque)
diff --git a/block/mirror.c b/block/mirror.c
index bed4a7e..3d5da7e 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -282,7 +282,7 @@ static void mirror_free_init(MirrorBlockJob *s)
}
}
-static void mirror_drain(MirrorBlockJob *s)
+static void coroutine_fn mirror_drain(MirrorBlockJob *s)
{
while (s->in_flight > 0) {
qemu_coroutine_yield();
@@ -390,7 +390,7 @@ static void coroutine_fn mirror_run(void *opaque)
should_complete = false;
if (s->in_flight == 0 && cnt == 0) {
trace_mirror_before_flush(s);
- ret = bdrv_flush(s->target);
+ ret = bdrv_co_flush(s->target);
if (ret < 0) {
if (mirror_error_action(s, false, -ret) == BDRV_ACTION_REPORT)
{
goto immediate_exit;
diff --git a/include/block/block.h b/include/block/block.h
index 65d8864..370b4c6 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -273,8 +273,8 @@ void bdrv_invalidate_cache_all(void);
void bdrv_clear_incoming_migration_all(void);
/* Ensure contents are flushed to disk. */
-int bdrv_flush(BlockDriverState *bs);
-int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
+int coroutine_fn bdrv_flush(BlockDriverState *bs);
+int bdrv_sync_flush(BlockDriverState *bs);
int bdrv_flush_all(void);
void bdrv_close_all(void);
void bdrv_drain_all(void);
--
1.8.3.2
- Re: [Qemu-devel] [RFC v2 04/15] Convert .bdrv_open and .bdrv_file_open to coroutine_fn, (continued)
- [Qemu-devel] [RFC v2 07/15] Call bdrv->open via a synchronous wrapper in block/snapshot.c, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 06/15] Explicitly mark BlockDriver functions .bdrv_write and .bdrv_read as coroutine functions, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 08/15] Convert bdrv_create and associated functions to be coroutine_fn, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 09/15] Add a synchronous wrapper bdrv_sync_rwco, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 11/15] Make bdrv_discard coroutine only and add bdrv_sync_discard, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 12/15] Make bdrv_flush coroutine only and add bdrv_sync_flush,
Charlie Shepherd <=
- [Qemu-devel] [RFC v2 10/15] Convert bdrv_read, bdrv_write and associated functions to coroutine functions, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 13/15] Introduce a run_handler function in qemu-img.c, Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 15/15] Add coroutine_fn annotations to nbd_co_* functions., Charlie Shepherd, 2013/08/09
- [Qemu-devel] [RFC v2 14/15] Add coroutine annotations for qemu_co_rwlock_rdlock and qemu_co_rwlock_wrlock, Charlie Shepherd, 2013/08/09
- Re: [Qemu-devel] [RFC v2 01/15] Add an explanation of when a function should be marked coroutine_fn, Stefan Hajnoczi, 2013/08/14
- Re: [Qemu-devel] [RFC v2 01/15] Add an explanation of when a function should be marked coroutine_fn, Stefan Hajnoczi, 2013/08/29