[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/19] vpc: Read/write multiple sectors at once
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 01/19] vpc: Read/write multiple sectors at once |
Date: |
Tue, 15 Jun 2010 16:19:23 +0200 |
This changes the vpc block driver (for VHD) to read/write multiple sectors at
once instead of doing a request for each single sector.
Before this, running qemu-iotests for VPC took ages, now it's actually quite
reasonable to run it always (down from ~1 hour to 40 seconds for me).
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vpc.c | 41 ++++++++++++++++++++++++++++++-----------
1 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 214e9d1..f1f73e2 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -371,23 +371,33 @@ fail:
static int vpc_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
+ BDRVVPCState *s = bs->opaque;
int ret;
int64_t offset;
+ int64_t sectors, sectors_per_block;
while (nb_sectors > 0) {
offset = get_sector_offset(bs, sector_num, 0);
+ sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;
+ sectors = sectors_per_block - (sector_num % sectors_per_block);
+ if (sectors > nb_sectors) {
+ sectors = nb_sectors;
+ }
+
if (offset == -1) {
- memset(buf, 0, 512);
+ memset(buf, 0, sectors * BDRV_SECTOR_SIZE);
} else {
- ret = bdrv_pread(bs->file, offset, buf, 512);
- if (ret != 512)
+ ret = bdrv_pread(bs->file, offset, buf,
+ sectors * BDRV_SECTOR_SIZE);
+ if (ret != sectors * BDRV_SECTOR_SIZE) {
return -1;
+ }
}
- nb_sectors--;
- sector_num++;
- buf += 512;
+ nb_sectors -= sectors;
+ sector_num += sectors;
+ buf += sectors * BDRV_SECTOR_SIZE;
}
return 0;
}
@@ -395,25 +405,34 @@ static int vpc_read(BlockDriverState *bs, int64_t
sector_num,
static int vpc_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
+ BDRVVPCState *s = bs->opaque;
int64_t offset;
+ int64_t sectors, sectors_per_block;
int ret;
while (nb_sectors > 0) {
offset = get_sector_offset(bs, sector_num, 1);
+ sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;
+ sectors = sectors_per_block - (sector_num % sectors_per_block);
+ if (sectors > nb_sectors) {
+ sectors = nb_sectors;
+ }
+
if (offset == -1) {
offset = alloc_block(bs, sector_num);
if (offset < 0)
return -1;
}
- ret = bdrv_pwrite(bs->file, offset, buf, 512);
- if (ret != 512)
+ ret = bdrv_pwrite(bs->file, offset, buf, sectors * BDRV_SECTOR_SIZE);
+ if (ret != sectors * BDRV_SECTOR_SIZE) {
return -1;
+ }
- nb_sectors--;
- sector_num++;
- buf += 512;
+ nb_sectors -= sectors;
+ sector_num += sectors;
+ buf += sectors * BDRV_SECTOR_SIZE;
}
return 0;
--
1.6.6.1
- [Qemu-devel] [PULL 00/19] Block patches, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 01/19] vpc: Read/write multiple sectors at once,
Kevin Wolf <=
- [Qemu-devel] [PATCH 03/19] qcow2: Allow alloc_clusters_noref to return errors, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 02/19] qcow2: Allow get_refcount to return errors, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 04/19] qcow2: Return real error code in load_refcount_block, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 05/19] savevm: Really verify if a drive supports snapshots, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 07/19] qcow2: Restore L1 entry on l2_allocate failure, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 08/19] cow: use pread/pwrite, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 06/19] Fix regression for "-drive file=", Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 10/19] cow: use qemu block API, Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 14/19] block: New bdrv_next(), Kevin Wolf, 2010/06/15
- [Qemu-devel] [PATCH 12/19] block: Decouple block device "commit all" from DriveInfo, Kevin Wolf, 2010/06/15