qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com, John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [PATCH v6 06/20] ide: Switch to byte-based aio block access
Date: Wed,  4 May 2016 17:55:12 -0600	[thread overview]
Message-ID: <1462406126-22946-7-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1462406126-22946-1-git-send-email-eblake@redhat.com>

Sector-based blk_aio_readv() and blk_aio_writev() should die; switch
to byte-based blk_aio_preadv() and blk_aio_pwritev() instead.

The patch had to touch multiple files at once, because dma_blk_io()
takes pointers to the functions, and ide_issue_trim() piggybacks on
the same interface (while ignoring offset under the hood).

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 hw/ide/internal.h    |  2 +-
 include/sysemu/dma.h |  4 ++--
 dma-helpers.c        | 14 +++++++-------
 hw/ide/core.c        | 10 +++++-----
 hw/ide/macio.c       |  9 +++------
 5 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index d2c458f..ceb9e59 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -614,7 +614,7 @@ void ide_transfer_start(IDEState *s, uint8_t *buf, int size,
 void ide_transfer_stop(IDEState *s);
 void ide_set_inactive(IDEState *s, bool more);
 BlockAIOCB *ide_issue_trim(BlockBackend *blk,
-        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
+        int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags,
         BlockCompletionFunc *cb, void *opaque);
 BlockAIOCB *ide_buffered_readv(IDEState *s, int64_t sector_num,
                                QEMUIOVector *iov, int nb_sectors,
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
index b0fbb9b..0f7cd4d 100644
--- a/include/sysemu/dma.h
+++ b/include/sysemu/dma.h
@@ -197,8 +197,8 @@ void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len);
 void qemu_sglist_destroy(QEMUSGList *qsg);
 #endif

-typedef BlockAIOCB *DMAIOFunc(BlockBackend *blk, int64_t sector_num,
-                              QEMUIOVector *iov, int nb_sectors,
+typedef BlockAIOCB *DMAIOFunc(BlockBackend *blk, int64_t offset,
+                              QEMUIOVector *iov, BdrvRequestFlags flags,
                               BlockCompletionFunc *cb, void *opaque);

 BlockAIOCB *dma_blk_io(BlockBackend *blk,
diff --git a/dma-helpers.c b/dma-helpers.c
index 4ad0bca..a6cc15f 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -73,7 +73,7 @@ typedef struct {
     BlockBackend *blk;
     BlockAIOCB *acb;
     QEMUSGList *sg;
-    uint64_t sector_num;
+    uint64_t offset;
     DMADirection dir;
     int sg_cur_index;
     dma_addr_t sg_cur_byte;
@@ -130,7 +130,7 @@ static void dma_blk_cb(void *opaque, int ret)
     trace_dma_blk_cb(dbs, ret);

     dbs->acb = NULL;
-    dbs->sector_num += dbs->iov.size / 512;
+    dbs->offset += dbs->iov.size;

     if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
         dma_complete(dbs, ret);
@@ -164,8 +164,8 @@ static void dma_blk_cb(void *opaque, int ret)
         qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK);
     }

-    dbs->acb = dbs->io_func(dbs->blk, dbs->sector_num, &dbs->iov,
-                            dbs->iov.size / 512, dma_blk_cb, dbs);
+    dbs->acb = dbs->io_func(dbs->blk, dbs->offset, &dbs->iov, 0,
+                            dma_blk_cb, dbs);
     assert(dbs->acb);
 }

@@ -203,7 +203,7 @@ BlockAIOCB *dma_blk_io(
     dbs->acb = NULL;
     dbs->blk = blk;
     dbs->sg = sg;
-    dbs->sector_num = sector_num;
+    dbs->offset = sector_num << BDRV_SECTOR_BITS;
     dbs->sg_cur_index = 0;
     dbs->sg_cur_byte = 0;
     dbs->dir = dir;
@@ -219,7 +219,7 @@ BlockAIOCB *dma_blk_read(BlockBackend *blk,
                          QEMUSGList *sg, uint64_t sector,
                          void (*cb)(void *opaque, int ret), void *opaque)
 {
-    return dma_blk_io(blk, sg, sector, blk_aio_readv, cb, opaque,
+    return dma_blk_io(blk, sg, sector, blk_aio_preadv, cb, opaque,
                       DMA_DIRECTION_FROM_DEVICE);
 }

@@ -227,7 +227,7 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk,
                           QEMUSGList *sg, uint64_t sector,
                           void (*cb)(void *opaque, int ret), void *opaque)
 {
-    return dma_blk_io(blk, sg, sector, blk_aio_writev, cb, opaque,
+    return dma_blk_io(blk, sg, sector, blk_aio_pwritev, cb, opaque,
                       DMA_DIRECTION_TO_DEVICE);
 }

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 41e6a2d..fe2bfba 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -442,7 +442,7 @@ static void ide_issue_trim_cb(void *opaque, int ret)
 }

 BlockAIOCB *ide_issue_trim(BlockBackend *blk,
-        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
+        int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags,
         BlockCompletionFunc *cb, void *opaque)
 {
     TrimAIOCB *iocb;
@@ -616,8 +616,8 @@ BlockAIOCB *ide_buffered_readv(IDEState *s, int64_t sector_num,
     req->iov.iov_len = iov->size;
     qemu_iovec_init_external(&req->qiov, &req->iov, 1);

-    aioreq = blk_aio_readv(s->blk, sector_num, &req->qiov, nb_sectors,
-                           ide_buffered_readv_cb, req);
+    aioreq = blk_aio_preadv(s->blk, sector_num << BDRV_SECTOR_BITS,
+                            &req->qiov, 0, ide_buffered_readv_cb, req);

     QLIST_INSERT_HEAD(&s->buffered_requests, req, list);
     return aioreq;
@@ -1006,8 +1006,8 @@ static void ide_sector_write(IDEState *s)

     block_acct_start(blk_get_stats(s->blk), &s->acct,
                      n * BDRV_SECTOR_SIZE, BLOCK_ACCT_WRITE);
-    s->pio_aiocb = blk_aio_writev(s->blk, sector_num, &s->qiov, n,
-                                  ide_sector_write_cb, s);
+    s->pio_aiocb = blk_aio_pwritev(s->blk, sector_num << BDRV_SECTOR_BITS,
+                                   &s->qiov, 0, ide_sector_write_cb, s);
 }

 static void ide_flush_cb(void *opaque, int ret)
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index ae29b6f..d7d9c0f 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -120,8 +120,7 @@ static void pmac_dma_read(BlockBackend *blk,
     MACIO_DPRINTF("--- Block read transfer - sector_num: %" PRIx64 "  "
                   "nsector: %x\n", (offset >> 9), (bytes >> 9));

-    s->bus->dma->aiocb = blk_aio_readv(blk, (offset >> 9), &io->iov,
-                             (bytes >> 9), cb, io);
+    s->bus->dma->aiocb = blk_aio_preadv(blk, offset, &io->iov, 0, cb, io);
 }

 static void pmac_dma_write(BlockBackend *blk,
@@ -205,8 +204,7 @@ static void pmac_dma_write(BlockBackend *blk,
     MACIO_DPRINTF("--- Block write transfer - sector_num: %" PRIx64 "  "
                   "nsector: %x\n", (offset >> 9), (bytes >> 9));

-    s->bus->dma->aiocb = blk_aio_writev(blk, (offset >> 9), &io->iov,
-                             (bytes >> 9), cb, io);
+    s->bus->dma->aiocb = blk_aio_pwritev(blk, offset, &io->iov, 0, cb, io);
 }

 static void pmac_dma_trim(BlockBackend *blk,
@@ -232,8 +230,7 @@ static void pmac_dma_trim(BlockBackend *blk,
     s->io_buffer_index += io->len;
     io->len = 0;

-    s->bus->dma->aiocb = ide_issue_trim(blk, (offset >> 9), &io->iov,
-                             (bytes >> 9), cb, io);
+    s->bus->dma->aiocb = ide_issue_trim(blk, offset, &io->iov, 0, cb, io);
 }

 static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
-- 
2.5.5

  parent reply	other threads:[~2016-05-04 23:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-04 23:55 [Qemu-devel] [PATCH v6 00/20] block: kill sector-based blk_write/read Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 01/20] block: Allow BDRV_REQ_FUA through blk_pwrite() Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 02/20] block: Drop private ioctl-only members of BlockRequest Eric Blake
2016-05-06 10:37   ` Kevin Wolf
2016-05-06 12:23     ` Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 03/20] block: Switch blk_read_unthrottled() to byte interface Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 04/20] block: Switch blk_*write_zeroes() " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 05/20] block: Introduce byte-based aio read/write Eric Blake
2016-05-06 12:31   ` Kevin Wolf
2016-05-06 14:12     ` Eric Blake
2016-05-04 23:55 ` Eric Blake [this message]
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 07/20] scsi-disk: Switch to byte-based aio block access Eric Blake
2016-05-06 12:50   ` Kevin Wolf
2016-05-06 14:18     ` Eric Blake
2016-05-06 14:49       ` Kevin Wolf
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 08/20] virtio: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 09/20] xen_disk: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 10/20] fdc: Switch to byte-based " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 11/20] nand: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 12/20] onenand: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 13/20] pflash: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 14/20] sd: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 15/20] m25p80: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 16/20] atapi: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 17/20] nbd: " Eric Blake
2016-05-06 13:08   ` Kevin Wolf
2016-05-06 14:19     ` Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 18/20] qemu-img: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 19/20] qemu-io: " Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 20/20] block: Kill unused sector-based blk_* functions Eric Blake
2016-05-06 13:11 ` [Qemu-devel] [PATCH v6 00/20] block: kill sector-based blk_write/read Kevin Wolf
2016-05-06 14:20   ` Eric Blake

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=1462406126-22946-7-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).