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 16/20] atapi: Switch to byte-based block access
Date: Wed, 4 May 2016 17:55:22 -0600 [thread overview]
Message-ID: <1462406126-22946-17-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1462406126-22946-1-git-send-email-eblake@redhat.com>
Sector-based blk_read() should die; switch to byte-based
blk_pread() instead.
Add new defines ATAPI_SECTOR_BITS and ATAPI_SECTOR_SIZE to
use anywhere we were previously scaling BDRV_SECTOR_* by 4,
for better legibility.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v4: add new defines for use in more places [jsnow]
---
hw/ide/atapi.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c
index 2bb606c..95056d9 100644
--- a/hw/ide/atapi.c
+++ b/hw/ide/atapi.c
@@ -28,6 +28,9 @@
#include "hw/scsi/scsi.h"
#include "sysemu/block-backend.h"
+#define ATAPI_SECTOR_BITS (2 + BDRV_SECTOR_BITS)
+#define ATAPI_SECTOR_SIZE (1 << ATAPI_SECTOR_BITS)
+
static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
static void padstr8(uint8_t *buf, int buf_size, const char *src)
@@ -111,7 +114,7 @@ cd_read_sector_sync(IDEState *s)
{
int ret;
block_acct_start(blk_get_stats(s->blk), &s->acct,
- 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
+ ATAPI_SECTOR_SIZE, BLOCK_ACCT_READ);
#ifdef DEBUG_IDE_ATAPI
printf("cd_read_sector_sync: lba=%d\n", s->lba);
@@ -119,12 +122,12 @@ cd_read_sector_sync(IDEState *s)
switch (s->cd_sector_size) {
case 2048:
- ret = blk_read(s->blk, (int64_t)s->lba << 2,
- s->io_buffer, 4);
+ ret = blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS,
+ s->io_buffer, ATAPI_SECTOR_SIZE);
break;
case 2352:
- ret = blk_read(s->blk, (int64_t)s->lba << 2,
- s->io_buffer + 16, 4);
+ ret = blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS,
+ s->io_buffer + 16, ATAPI_SECTOR_SIZE);
if (ret >= 0) {
cd_data_to_raw(s->io_buffer, s->lba);
}
@@ -182,7 +185,7 @@ static int cd_read_sector(IDEState *s)
s->iov.iov_base = (s->cd_sector_size == 2352) ?
s->io_buffer + 16 : s->io_buffer;
- s->iov.iov_len = 4 * BDRV_SECTOR_SIZE;
+ s->iov.iov_len = ATAPI_SECTOR_SIZE;
qemu_iovec_init_external(&s->qiov, &s->iov, 1);
#ifdef DEBUG_IDE_ATAPI
@@ -190,7 +193,7 @@ static int cd_read_sector(IDEState *s)
#endif
block_acct_start(blk_get_stats(s->blk), &s->acct,
- 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ);
+ ATAPI_SECTOR_SIZE, BLOCK_ACCT_READ);
ide_buffered_readv(s, (int64_t)s->lba << 2, &s->qiov, 4,
cd_read_sector_cb, s);
@@ -435,7 +438,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret)
#endif
s->bus->dma->iov.iov_base = (void *)(s->io_buffer + data_offset);
- s->bus->dma->iov.iov_len = n * 4 * 512;
+ s->bus->dma->iov.iov_len = n * ATAPI_SECTOR_SIZE;
qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1);
s->bus->dma->aiocb = ide_buffered_readv(s, (int64_t)s->lba << 2,
--
2.5.5
next prev parent reply other threads:[~2016-05-04 23:57 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 ` [Qemu-devel] [PATCH v6 06/20] ide: Switch to byte-based aio block access Eric Blake
2016-05-04 23:55 ` [Qemu-devel] [PATCH v6 07/20] scsi-disk: " 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 ` Eric Blake [this message]
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-17-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).