[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/27] block/parallels: switch to bdrv_read
From: |
Denis V. Lunev |
Subject: |
[Qemu-devel] [PATCH 03/27] block/parallels: switch to bdrv_read |
Date: |
Wed, 11 Mar 2015 13:27:57 +0300 |
From: Roman Kagan <address@hidden>
Switch the .bdrv_read method implementation from using bdrv_pread() to
bdrv_read() on the underlying file, since the latter is subject to i/o
throttling while the former is not.
Besides, since bdrv_read() operates in sectors rather than bytes, adjust
the helper functions to do so too.
Signed-off-by: Roman Kagan <address@hidden>
Reviewed-by: Denis V. Lunev <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Kevin Wolf <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
---
block/parallels.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index dca0df6..baefd3e 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -146,9 +146,8 @@ fail:
return ret;
}
-static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
+static int64_t seek_to_sector(BDRVParallelsState *s, int64_t sector_num)
{
- BDRVParallelsState *s = bs->opaque;
uint32_t index, offset;
index = sector_num / s->tracks;
@@ -157,24 +156,27 @@ static int64_t seek_to_sector(BlockDriverState *bs,
int64_t sector_num)
/* not allocated */
if ((index >= s->catalog_size) || (s->catalog_bitmap[index] == 0))
return -1;
- return
- ((uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset) *
512;
+ return (uint64_t)s->catalog_bitmap[index] * s->off_multiplier + offset;
}
static int parallels_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
+ BDRVParallelsState *s = bs->opaque;
+
while (nb_sectors > 0) {
- int64_t position = seek_to_sector(bs, sector_num);
+ int64_t position = seek_to_sector(s, sector_num);
if (position >= 0) {
- if (bdrv_pread(bs->file, position, buf, 512) != 512)
- return -1;
+ int ret = bdrv_read(bs->file, position, buf, 1);
+ if (ret < 0) {
+ return ret;
+ }
} else {
- memset(buf, 0, 512);
+ memset(buf, 0, BDRV_SECTOR_SIZE);
}
nb_sectors--;
sector_num++;
- buf += 512;
+ buf += BDRV_SECTOR_SIZE;
}
return 0;
}
--
1.9.1
- [Qemu-devel] [PATCH 07/27] block/parallels: replace magic constants 4, 64 with proper sizeofs, (continued)
- [Qemu-devel] [PATCH 07/27] block/parallels: replace magic constants 4, 64 with proper sizeofs, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 24/27] block/parallels: delay writing to BAT till bdrv_co_flush_to_os, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 21/27] block/parallels: no need to flush on each block allocation table update, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH 02/27] block/parallels: rename parallels_header to ParallelsHeader, Denis V. Lunev, 2015/03/10
- [Qemu-devel] [PATCH v3 0/27] write/create for Parallels images with reasonable performance, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 22/27] block/parallels: improve image reading performance, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 05/27] block/parallels: add get_block_status, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 01/27] iotests, parallels: quote TEST_IMG in 076 test to be path-safe, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 03/27] block/parallels: switch to bdrv_read,
Denis V. Lunev <=
- [Qemu-devel] [PATCH 24/27] block/parallels: delay writing to BAT till bdrv_co_flush_to_os, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 13/27] block/parallels: rename catalog_ names to bat_, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 10/27] block/parallels: support parallels image creation, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 27/27] block/parallels: improve image writing performance further, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 19/27] block/parallels: implement incorrect close detection, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 11/27] iotests, parallels: test for newly created parallels image via qemu-img, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 15/27] block/parallels: keep BAT bitmap data in little endian in memory, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 18/27] block/parallels: implement parallels_check method of block driver, Denis V. Lunev, 2015/03/11
- [Qemu-devel] [PATCH 21/27] block/parallels: no need to flush on each block allocation table update, Denis V. Lunev, 2015/03/11