[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/38] ide: convert ide_sector_write() to asynchrono
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 08/38] ide: convert ide_sector_write() to asynchronous I/O |
Date: |
Fri, 20 Apr 2012 19:01:14 +0200 |
From: Stefan Hajnoczi <address@hidden>
The IDE PIO write sector code path uses bdrv_write() and hence can make
the guest unresponsive while the I/O request is in progress. This patch
converts ide_sector_write() to use bdrv_aio_writev() by using the
BUSY_STAT bit to tell the guest that the request is in progress.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Zhi Yong Wu <address@hidden>
Tested-by: Richard Davies <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/ide/core.c | 61 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 9894b3b..a5216a6 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -688,40 +688,39 @@ static void ide_sector_write_timer_cb(void *opaque)
ide_set_irq(s->bus);
}
-void ide_sector_write(IDEState *s)
+static void ide_sector_write_cb(void *opaque, int ret)
{
- int64_t sector_num;
- int ret, n, n1;
-
- s->status = READY_STAT | SEEK_STAT;
- sector_num = ide_get_sector(s);
-#if defined(DEBUG_IDE)
- printf("write sector=%" PRId64 "\n", sector_num);
-#endif
- n = s->nsector;
- if (n > s->req_nb_sectors)
- n = s->req_nb_sectors;
+ IDEState *s = opaque;
+ int n;
- bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);
- ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);
bdrv_acct_done(s->bs, &s->acct);
+ s->pio_aiocb = NULL;
+ s->status &= ~BUSY_STAT;
+
if (ret != 0) {
- if (ide_handle_rw_error(s, -ret, BM_STATUS_PIO_RETRY))
+ if (ide_handle_rw_error(s, -ret, BM_STATUS_PIO_RETRY)) {
return;
+ }
}
+ n = s->nsector;
+ if (n > s->req_nb_sectors) {
+ n = s->req_nb_sectors;
+ }
s->nsector -= n;
if (s->nsector == 0) {
/* no more sectors to write */
ide_transfer_stop(s);
} else {
- n1 = s->nsector;
- if (n1 > s->req_nb_sectors)
+ int n1 = s->nsector;
+ if (n1 > s->req_nb_sectors) {
n1 = s->req_nb_sectors;
- ide_transfer_start(s, s->io_buffer, 512 * n1, ide_sector_write);
+ }
+ ide_transfer_start(s, s->io_buffer, n1 * BDRV_SECTOR_SIZE,
+ ide_sector_write);
}
- ide_set_sector(s, sector_num + n);
+ ide_set_sector(s, ide_get_sector(s) + n);
if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
/* It seems there is a bug in the Windows 2000 installer HDD
@@ -737,6 +736,30 @@ void ide_sector_write(IDEState *s)
}
}
+void ide_sector_write(IDEState *s)
+{
+ int64_t sector_num;
+ int n;
+
+ s->status = READY_STAT | SEEK_STAT | BUSY_STAT;
+ sector_num = ide_get_sector(s);
+#if defined(DEBUG_IDE)
+ printf("sector=%" PRId64 "\n", sector_num);
+#endif
+ n = s->nsector;
+ if (n > s->req_nb_sectors) {
+ n = s->req_nb_sectors;
+ }
+
+ s->iov.iov_base = s->io_buffer;
+ s->iov.iov_len = n * BDRV_SECTOR_SIZE;
+ qemu_iovec_init_external(&s->qiov, &s->iov, 1);
+
+ bdrv_acct_start(s->bs, &s->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);
+ s->pio_aiocb = bdrv_aio_writev(s->bs, sector_num, &s->qiov, n,
+ ide_sector_write_cb, s);
+}
+
static void ide_flush_cb(void *opaque, int ret)
{
IDEState *s = opaque;
--
1.7.6.5
- [Qemu-devel] [PULL 00/38] Block patches, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 03/38] block: Drain requests in bdrv_close, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 02/38] qemu-iotests: Test bdrv_close while AIO is in flight, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 01/38] qemu-iotests: Always filter cluster_size out in _make_test_img, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 06/38] qemu-io: Add command line switch for cache mode, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 05/38] block: Fix spelling in comment (ineffcient -> inefficient), Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 04/38] iotests: fix error in 005, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 07/38] ide: convert ide_sector_read() to asynchronous I/O, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 10/38] qcow2: Fix return value of alloc_refcount_block, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 09/38] qcow2: Fix error handling in qcow2_alloc_cluster_offset, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 08/38] ide: convert ide_sector_write() to asynchronous I/O,
Kevin Wolf <=
- [Qemu-devel] [PATCH 12/38] qemu-io: use main_loop_wait, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 13/38] qemu-tool: map vm_clock to rt_clock, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 11/38] block: allow interrupting a co_sleep_ns, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 17/38] aio: simplify qemu_aio_wait, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 14/38] posix-aio: merge posix_aio_process_queue and posix_aio_read, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 16/38] aio: return "AIO in progress" state from qemu_aio_wait, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 18/38] qemu-img: let 'qemu-img convert' flush data, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 19/38] iotests: Resolve test failures caused by hostname, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 15/38] aio: remove process_queue callback and qemu_aio_process_queue, Kevin Wolf, 2012/04/20
- [Qemu-devel] [PATCH 20/38] qcow2: Fix refcount block allocation during qcow2_alloc_cluster_at(), Kevin Wolf, 2012/04/20