[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/5] block/vpc: optimize vpc_co_get_block_status
From: |
Peter Lieven |
Subject: |
[Qemu-devel] [PATCH v2 1/5] block/vpc: optimize vpc_co_get_block_status |
Date: |
Tue, 3 Mar 2015 11:41:52 +0100 |
*pnum can't be greater than s->block_size / BDRV_SECTOR_SIZE for allocated
sectors since there is always a bitmap in between.
Signed-off-by: Peter Lieven <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/vpc.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 1533b6a..c8e17cb 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -602,7 +602,7 @@ static int64_t coroutine_fn
vpc_co_get_block_status(BlockDriverState *bs,
{
BDRVVPCState *s = bs->opaque;
VHDFooter *footer = (VHDFooter*) s->footer_buf;
- int64_t start, offset, next;
+ int64_t start, offset;
bool allocated;
int n;
@@ -626,20 +626,18 @@ static int64_t coroutine_fn
vpc_co_get_block_status(BlockDriverState *bs,
*pnum += n;
sector_num += n;
nb_sectors -= n;
- next = start + (*pnum * BDRV_SECTOR_SIZE);
-
+ /* *pnum can't be greater than one block for allocated
+ * sectors since there is always a bitmap in between. */
+ if (allocated) {
+ return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
+ }
if (nb_sectors == 0) {
break;
}
-
offset = get_sector_offset(bs, sector_num, 0);
- } while ((allocated && offset == next) || (!allocated && offset == -1));
+ } while (offset == -1);
- if (allocated) {
- return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start;
- } else {
- return 0;
- }
+ return 0;
}
/*
--
1.9.1
- [Qemu-devel] [PATCH v2 0/5] block/vpc optimizations, Peter Lieven, 2015/03/03
- [Qemu-devel] [PATCH v2 4/5] block/vpc: rename footer->size -> footer->current_size, Peter Lieven, 2015/03/03
- [Qemu-devel] [PATCH v2 3/5] block/vpc: make calculate_geometry spec conform, Peter Lieven, 2015/03/03
- [Qemu-devel] [PATCH v2 1/5] block/vpc: optimize vpc_co_get_block_status,
Peter Lieven <=
- [Qemu-devel] [PATCH v2 2/5] vpc: Ignore geometry for large images, Peter Lieven, 2015/03/03
- [Qemu-devel] [PATCH v2 5/5] block/vpc: remove disabled code from get_sector_offset, Peter Lieven, 2015/03/03
- Re: [Qemu-devel] [PATCH v2 0/5] block/vpc optimizations, Max Reitz, 2015/03/03