[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/8] block: Use new AsyncContext for bdrv_read/write
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 5/8] block: Use new AsyncContext for bdrv_read/write emulation |
Date: |
Thu, 22 Oct 2009 17:54:39 +0200 |
bdrv_read/write emulation is used as the perfect example why we need something
like AsyncContexts. So maybe they better start using it.
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 33f3d65..fa0de25 100644
--- a/block.c
+++ b/block.c
@@ -1696,19 +1696,26 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t
sector_num,
struct iovec iov;
QEMUIOVector qiov;
+ async_context_push();
+
async_ret = NOT_DONE;
iov.iov_base = (void *)buf;
iov.iov_len = nb_sectors * 512;
qemu_iovec_init_external(&qiov, &iov, 1);
acb = bdrv_aio_readv(bs, sector_num, &qiov, nb_sectors,
bdrv_rw_em_cb, &async_ret);
- if (acb == NULL)
- return -1;
+ if (acb == NULL) {
+ async_ret = -1;
+ goto fail;
+ }
while (async_ret == NOT_DONE) {
qemu_aio_wait();
}
+
+fail:
+ async_context_pop();
return async_ret;
}
@@ -1720,17 +1727,24 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t
sector_num,
struct iovec iov;
QEMUIOVector qiov;
+ async_context_push();
+
async_ret = NOT_DONE;
iov.iov_base = (void *)buf;
iov.iov_len = nb_sectors * 512;
qemu_iovec_init_external(&qiov, &iov, 1);
acb = bdrv_aio_writev(bs, sector_num, &qiov, nb_sectors,
bdrv_rw_em_cb, &async_ret);
- if (acb == NULL)
- return -1;
+ if (acb == NULL) {
+ async_ret = -1;
+ goto fail;
+ }
while (async_ret == NOT_DONE) {
qemu_aio_wait();
}
+
+fail:
+ async_context_pop();
return async_ret;
}
--
1.6.2.5
- [Qemu-devel] [PATCH 0/8] Fix bdrv_read/write emulation, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 1/8] posix-aio-compat: Split out posix_aio_process_queue, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 2/8] Add qemu_aio_process_queue(), Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 3/8] Split out bottom halves, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 4/8] Introduce contexts for asynchronous callbacks, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 6/8] posix-aio-compat: Honour AsyncContext, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 7/8] linux-aio: Honour AsyncContext, Kevin Wolf, 2009/10/22
- [Qemu-devel] [PATCH 5/8] block: Use new AsyncContext for bdrv_read/write emulation,
Kevin Wolf <=
- [Qemu-devel] [PATCH 8/8] Revert "qcow2: Bring synchronous read/write back to life", Kevin Wolf, 2009/10/22