Message ID | 1424701661-21241-2-git-send-email-pl@kamp.de |
---|---|
State | New |
Headers | show |
On 2015-02-23 at 09:27, Peter Lieven wrote: > *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> > --- > block/vpc.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) I would like a comment about this in or above the "if (allocated)" in the do-while loop, but in any case: Reviewed-by: Max Reitz <mreitz@redhat.com>
Am 23.02.2015 um 19:08 schrieb Max Reitz: > On 2015-02-23 at 09:27, Peter Lieven wrote: >> *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> >> --- >> block/vpc.c | 15 ++++++--------- >> 1 file changed, 6 insertions(+), 9 deletions(-) > > I would like a comment about this in or above the "if (allocated)" in the do-while loop, but in any case: Will add in v2. Peter > > Reviewed-by: Max Reitz <mreitz@redhat.com>
diff --git a/block/vpc.c b/block/vpc.c index 1533b6a..326c2bb 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,17 @@ 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); + 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; } /*
*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> --- block/vpc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)