@@ -1676,17 +1676,17 @@ int bdrv_flush_all(void)
}
-typedef struct BdrvCoGetBlockStatusData {
+typedef struct BdrvCoBlockStatusData {
BlockDriverState *bs;
BlockDriverState *base;
BlockDriverState **file;
- int64_t sector_num;
- int nb_sectors;
- int *pnum;
+ int64_t offset;
+ int64_t bytes;
+ int64_t *pnum;
int64_t ret;
bool allocation;
bool done;
-} BdrvCoGetBlockStatusData;
+} BdrvCoBlockStatusData;
int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
int64_t sector_num,
@@ -1913,14 +1913,16 @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs,
/* Coroutine wrapper for bdrv_get_block_status_above() */
static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque)
{
- BdrvCoGetBlockStatusData *data = opaque;
+ BdrvCoBlockStatusData *data = opaque;
+ int n;
data->ret = bdrv_co_get_block_status_above(data->bs, data->base,
data->allocation,
- data->sector_num,
- data->nb_sectors,
- data->pnum,
+ data->offset >> BDRV_SECTOR_BITS,
+ data->bytes >> BDRV_SECTOR_BITS,
+ &n,
data->file);
+ *data->pnum = n * BDRV_SECTOR_SIZE;
data->done = true;
}
@@ -1937,13 +1939,14 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs,
BlockDriverState **file)
{
Coroutine *co;
- BdrvCoGetBlockStatusData data = {
+ int64_t n;
+ BdrvCoBlockStatusData data = {
.bs = bs,
.base = base,
.file = file,
- .sector_num = sector_num,
- .nb_sectors = nb_sectors,
- .pnum = pnum,
+ .offset = sector_num * BDRV_SECTOR_SIZE,
+ .bytes = nb_sectors * BDRV_SECTOR_SIZE,
+ .pnum = &n,
.allocation = allocation,
.done = false,
};
@@ -1957,6 +1960,8 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs,
bdrv_coroutine_enter(bs, co);
BDRV_POLL_WHILE(bs, !data.done);
}
+ assert(data.ret < 0 || QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE));
+ *pnum = n >> BDRV_SECTOR_BITS;
return data.ret;
}
We are gradually converting to byte-based interfaces, as they are easier to reason about than sector-based. Convert another internal type (no semantic change), and rename it to match the corresponding public function rename. Signed-off-by: Eric Blake <eblake@redhat.com> --- v2: rebase to earlier changes --- block/io.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)