diff options
author | Peter Lieven <pl@kamp.de> | 2015-03-03 11:41:52 +0100 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2015-03-16 12:10:30 -0400 |
commit | 2ec711dcd45effc8d583dee6ff92d94573aad75b (patch) | |
tree | d4ce6f22e5d6d1a5508366af204b18029ff0580c /block/vpc.c | |
parent | d51a2427f68a312b676edd0e9efce881649d1767 (diff) |
block/vpc: optimize vpc_co_get_block_status
*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 <pl@kamp.de>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1425379316-19639-2-git-send-email-pl@kamp.de
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/vpc.c')
-rw-r--r-- | block/vpc.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/block/vpc.c b/block/vpc.c index 1533b6a64d..c8e17cb058 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; } /* |