[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/14] make dma_bdrv_io available to drivers
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 10/14] make dma_bdrv_io available to drivers |
Date: |
Wed, 15 Jun 2011 16:03:09 +0200 |
From: Christoph Hellwig <address@hidden>
Make dma_bdrv_io available for drivers, and pass an explicit I/O function
instead of hardcoding bdrv_aio_readv/bdrv_aio_writev. This is required
to implement non-READ/WRITE dma commands in the ide driver, e.g. the
upcoming TRIM support.
Signed-off-by: Christoph Hellwig <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
dma-helpers.c | 23 ++++++++++-------------
dma.h | 8 ++++++++
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/dma-helpers.c b/dma-helpers.c
index 712ed89..ba7f897 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -47,6 +47,7 @@ typedef struct {
target_phys_addr_t sg_cur_byte;
QEMUIOVector iov;
QEMUBH *bh;
+ DMAIOFunc *io_func;
} DMAAIOCB;
static void dma_bdrv_cb(void *opaque, int ret);
@@ -116,13 +117,8 @@ static void dma_bdrv_cb(void *opaque, int ret)
return;
}
- if (dbs->is_write) {
- dbs->acb = bdrv_aio_writev(dbs->bs, dbs->sector_num, &dbs->iov,
- dbs->iov.size / 512, dma_bdrv_cb, dbs);
- } else {
- dbs->acb = bdrv_aio_readv(dbs->bs, dbs->sector_num, &dbs->iov,
- dbs->iov.size / 512, dma_bdrv_cb, dbs);
- }
+ dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,
+ dbs->iov.size / 512, dma_bdrv_cb, dbs);
if (!dbs->acb) {
dma_bdrv_unmap(dbs);
qemu_iovec_destroy(&dbs->iov);
@@ -144,12 +140,12 @@ static AIOPool dma_aio_pool = {
.cancel = dma_aio_cancel,
};
-static BlockDriverAIOCB *dma_bdrv_io(
+BlockDriverAIOCB *dma_bdrv_io(
BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num,
- BlockDriverCompletionFunc *cb, void *opaque,
- int is_write)
+ DMAIOFunc *io_func, BlockDriverCompletionFunc *cb,
+ void *opaque, int is_write)
{
- DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
+ DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque);
dbs->acb = NULL;
dbs->bs = bs;
@@ -158,6 +154,7 @@ static BlockDriverAIOCB *dma_bdrv_io(
dbs->sg_cur_index = 0;
dbs->sg_cur_byte = 0;
dbs->is_write = is_write;
+ dbs->io_func = io_func;
dbs->bh = NULL;
qemu_iovec_init(&dbs->iov, sg->nsg);
dma_bdrv_cb(dbs, 0);
@@ -173,12 +170,12 @@ BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
QEMUSGList *sg, uint64_t sector,
void (*cb)(void *opaque, int ret), void
*opaque)
{
- return dma_bdrv_io(bs, sg, sector, cb, opaque, 0);
+ return dma_bdrv_io(bs, sg, sector, bdrv_aio_readv, cb, opaque, 0);
}
BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs,
QEMUSGList *sg, uint64_t sector,
void (*cb)(void *opaque, int ret), void
*opaque)
{
- return dma_bdrv_io(bs, sg, sector, cb, opaque, 1);
+ return dma_bdrv_io(bs, sg, sector, bdrv_aio_writev, cb, opaque, 1);
}
diff --git a/dma.h b/dma.h
index f3bb275..3d8324b 100644
--- a/dma.h
+++ b/dma.h
@@ -32,6 +32,14 @@ void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t
base,
target_phys_addr_t len);
void qemu_sglist_destroy(QEMUSGList *qsg);
+typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
+ QEMUIOVector *iov, int nb_sectors,
+ BlockDriverCompletionFunc *cb, void *opaque);
+
+BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs,
+ QEMUSGList *sg, uint64_t sector_num,
+ DMAIOFunc *io_func, BlockDriverCompletionFunc
*cb,
+ void *opaque, int is_write);
BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs,
QEMUSGList *sg, uint64_t sector,
BlockDriverCompletionFunc *cb, void *opaque);
--
1.7.5.2
- [Qemu-devel] [PULL 00/14] Block patches, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 01/14] block/rbd: Remove unused local variable, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 04/14] vdi: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 02/14] qcow2: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 06/14] qcow2: Fix in-flight list after qcow2_cache_put failure, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 05/14] Replaced tabs with spaces in block.h and block_int.h, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 07/14] ide: Split error status from status register, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 08/14] ide: Fix ide_drive_pio_state_needed(), Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 09/14] ide: Add forgotten VMSTATE_END_OF_LIST in subsection, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 10/14] make dma_bdrv_io available to drivers,
Kevin Wolf <=
- [Qemu-devel] [PATCH 11/14] ide: allow other dma comands than read and write, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 13/14] ide: Clear error_status after restarting flush, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 03/14] qcow: Avoid direct AIO callback, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 14/14] Allow nested qemu_bh_poll() after BH deletion, Kevin Wolf, 2011/06/15
- [Qemu-devel] [PATCH 12/14] ide: add TRIM support, Kevin Wolf, 2011/06/15
- Re: [Qemu-devel] [PULL 00/14] Block patches, Anthony Liguori, 2011/06/15