From: Christoph Hellwig <hch@lst.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/7] make dma_bdrv_io available to drivers
Date: Fri, 10 Dec 2010 16:01:06 +0100 [thread overview]
Message-ID: <20101210150106.GC31114@lst.de> (raw)
In-Reply-To: <20101210150038.GA30990@lst.de>
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 <hch@lst.de>
Index: qemu/dma-helpers.c
===================================================================
--- qemu.orig/dma-helpers.c 2010-11-23 14:13:42.178253390 +0100
+++ qemu/dma-helpers.c 2010-11-23 14:14:45.186253110 +0100
@@ -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, in
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(BlockDri
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);
}
Index: qemu/dma.h
===================================================================
--- qemu.orig/dma.h 2010-11-23 14:13:42.185253809 +0100
+++ qemu/dma.h 2010-11-23 14:14:45.186253110 +0100
@@ -32,6 +32,14 @@ void qemu_sglist_add(QEMUSGList *qsg, ta
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);
next prev parent reply other threads:[~2010-12-10 15:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 15:00 [Qemu-devel] ]PATCH 0/7] add TRIM/UNMAP support, v3 Christoph Hellwig
2010-12-10 15:00 ` [Qemu-devel] [PATCH 1/7] block: add discard support Christoph Hellwig
2010-12-10 15:00 ` [Qemu-devel] [PATCH 2/7] scsi-disk: support WRITE SAME (16) with unmap bit Christoph Hellwig
2010-12-16 15:48 ` Kevin Wolf
2010-12-16 16:41 ` Christoph Hellwig
2010-12-10 15:01 ` Christoph Hellwig [this message]
2010-12-10 15:01 ` [Qemu-devel] [PATCH 4/7] ide: factor dma handling helpers Christoph Hellwig
2010-12-10 15:01 ` [Qemu-devel] [PATCH 5/7] ide: also reset io_buffer_index for writes Christoph Hellwig
2010-12-10 15:01 ` [Qemu-devel] [PATCH 6/7] ide: add TRIM support Christoph Hellwig
2010-12-10 15:01 ` [Qemu-devel] [PATCH 7/7] raw-posix: add discard support Christoph Hellwig
2010-12-12 15:28 ` [Qemu-devel] ]PATCH 0/7] add TRIM/UNMAP support, v3 Stefan Hajnoczi
2010-12-13 15:45 ` Christoph Hellwig
2010-12-16 15:43 ` Kevin Wolf
2010-12-16 16:42 ` Christoph Hellwig
2010-12-16 18:36 ` [Qemu-devel] Re: [PATCH 0/3] add TRIM/UNMAP support, v4 Christoph Hellwig
2010-12-16 18:36 ` [Qemu-devel] [PATCH 1/3] block: add discard support Christoph Hellwig
2010-12-16 18:36 ` [Qemu-devel] [PATCH 2/3] scsi-disk: support WRITE SAME (16) with unmap bit Christoph Hellwig
2010-12-16 18:36 ` [Qemu-devel] [PATCH 3/3] raw-posix: add discard support Christoph Hellwig
2010-12-17 10:32 ` Kevin Wolf
2010-12-17 10:41 ` [Qemu-devel] [PATCH v5] " Christoph Hellwig
2010-12-17 10:53 ` [Qemu-devel] " Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101210150106.GC31114@lst.de \
--to=hch@lst.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).