From 8b94ff85737062876c03e7506abb500521c749b9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 20 Oct 2011 13:16:24 +0200 Subject: block: change flush to co_flush Since coroutine operation is now mandatory, convert all bdrv_flush implementations to coroutines. For qcow2, this means taking the lock. Other implementations are simpler and just forward bdrv_flush to the underlying protocol, so they can avoid the lock. The bdrv_flush callback is then unused and can be eliminated. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- block/qcow2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'block/qcow2.c') diff --git a/block/qcow2.c b/block/qcow2.c index 91f4f04dd..6ef38bf1b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1099,24 +1099,24 @@ fail: return ret; } -static BlockDriverAIOCB *qcow2_aio_flush(BlockDriverState *bs, - BlockDriverCompletionFunc *cb, - void *opaque) +static int qcow2_co_flush(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; int ret; + qemu_co_mutex_lock(&s->lock); ret = qcow2_cache_flush(bs, s->l2_table_cache); if (ret < 0) { - return NULL; + return ret; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); if (ret < 0) { - return NULL; + return ret; } + qemu_co_mutex_unlock(&s->lock); - return bdrv_aio_flush(bs->file, cb, opaque); + return bdrv_co_flush(bs->file); } static int64_t qcow2_vm_state_offset(BDRVQcowState *s) @@ -1237,7 +1237,7 @@ static BlockDriver bdrv_qcow2 = { .bdrv_co_readv = qcow2_co_readv, .bdrv_co_writev = qcow2_co_writev, - .bdrv_aio_flush = qcow2_aio_flush, + .bdrv_co_flush = qcow2_co_flush, .bdrv_discard = qcow2_discard, .bdrv_truncate = qcow2_truncate, -- cgit v1.2.3