[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access |
Date: |
Thu, 12 May 2016 16:35:23 +0200 |
From: Eric Blake <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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,
--
1.8.3.1
- [Qemu-devel] [PULL 50/69] block: Honor BDRV_REQ_FUA during write_zeroes, (continued)
- [Qemu-devel] [PULL 50/69] block: Honor BDRV_REQ_FUA during write_zeroes, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 33/69] ide: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 49/69] block: Make supported_write_flags a per-bds property, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 35/69] virtio: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 38/69] nand: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 40/69] pflash: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 59/69] qmp: add monitor command to add/remove a child, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 36/69] xen_disk: Switch to byte-based aio block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 42/69] m25p80: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 69/69] qemu-iotests: iotests: fail hard if not run via "check", Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 43/69] atapi: Switch to byte-based block access,
Kevin Wolf <=
- [Qemu-devel] [PULL 45/69] qemu-img: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 52/69] block: Invalidate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 55/69] iotests: fix the redirection order in 083, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 64/69] qemu-io: Add 'write -f' to test FUA flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 67/69] block: add support for encryption secrets in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 41/69] sd: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 56/69] qemu-img: check block status of backing file when converting., Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 53/69] block: Drop superfluous invalidating bs->file from drivers, Kevin Wolf, 2016/05/12