[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/16] block/parallels: switch to bdrv_read
From: |
Denis V. Lunev |
Subject: |
[Qemu-devel] [PATCH 08/16] block/parallels: switch to bdrv_read |
Date: |
Mon, 15 Dec 2014 11:27:53 +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>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Jeff Cody <address@hidden>
CC: Kevin Wolf <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
---
block/parallels.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index 5fcede8..de4f39f 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -364,9 +364,8 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
}
-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;
@@ -375,8 +374,7 @@ 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,
@@ -387,16 +385,18 @@ static int parallels_read(BlockDriverState *bs, int64_t
sector_num,
sector_num += s->padding;
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
- Re: [Qemu-devel] [PATCH 14/16] block/parallels: introduce ParallelsSnapshot data structure, (continued)
- [Qemu-devel] [PATCH 11/16] block/parallels: add support for backing files, Denis V. Lunev, 2014/12/15
- [Qemu-devel] [PATCH 10/16] block/parallels: add get_block_status, Denis V. Lunev, 2014/12/15
- [Qemu-devel] [PATCH 09/16] block/parallels: read up to cluster end in one go, Denis V. Lunev, 2014/12/15
- [Qemu-devel] [PATCH 12/16] iotests: testcase for backing in parallels format, Denis V. Lunev, 2014/12/15
- [Qemu-devel] [PATCH 08/16] block/parallels: switch to bdrv_read,
Denis V. Lunev <=
- [Qemu-devel] [PATCH 01/16] configure: add dependency from libxml2, Denis V. Lunev, 2014/12/15