diff options
author | Eric Blake <eblake@redhat.com> | 2017-10-11 22:47:05 -0500 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-10-26 14:45:57 +0200 |
commit | 4bcd936e47c45ebf7236b0414982dd625a957410 (patch) | |
tree | 89d571f7d780c53e079d077151da89835dc345ff /block | |
parent | 2e8bc7874bb674b7d6837706b1249bf871941637 (diff) | |
download | qemu-4bcd936e47c45ebf7236b0414982dd625a957410.zip qemu-4bcd936e47c45ebf7236b0414982dd625a957410.tar.gz qemu-4bcd936e47c45ebf7236b0414982dd625a957410.tar.bz2 |
block: Switch BdrvCoGetBlockStatusData to byte-based
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>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/io.c | 56 |
1 files changed, 38 insertions, 18 deletions
@@ -1765,17 +1765,18 @@ int bdrv_flush_all(void) } -typedef struct BdrvCoGetBlockStatusData { +typedef struct BdrvCoBlockStatusData { BlockDriverState *bs; BlockDriverState *base; bool want_zero; - int64_t sector_num; - int nb_sectors; - int *pnum; + int64_t offset; + int64_t bytes; + int64_t *pnum; + int64_t *map; BlockDriverState **file; - int64_t ret; + int ret; bool done; -} BdrvCoGetBlockStatusData; +} BdrvCoBlockStatusData; int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs, int64_t sector_num, @@ -2025,14 +2026,24 @@ 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 = 0; + int64_t ret; - data->ret = bdrv_co_get_block_status_above(data->bs, data->base, - data->want_zero, - data->sector_num, - data->nb_sectors, - data->pnum, - data->file); + ret = bdrv_co_get_block_status_above(data->bs, data->base, + data->want_zero, + data->offset >> BDRV_SECTOR_BITS, + data->bytes >> BDRV_SECTOR_BITS, + &n, + data->file); + if (ret < 0) { + assert(INT_MIN <= ret); + data->ret = ret; + } else { + *data->pnum = n * BDRV_SECTOR_SIZE; + *data->map = ret & BDRV_BLOCK_OFFSET_MASK; + data->ret = ret & ~BDRV_BLOCK_OFFSET_MASK; + } data->done = true; } @@ -2049,13 +2060,16 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, BlockDriverState **file) { Coroutine *co; - BdrvCoGetBlockStatusData data = { + int64_t n; + int64_t map; + BdrvCoBlockStatusData data = { .bs = bs, .base = base, .want_zero = want_zero, - .sector_num = sector_num, - .nb_sectors = nb_sectors, - .pnum = pnum, + .offset = sector_num * BDRV_SECTOR_SIZE, + .bytes = nb_sectors * BDRV_SECTOR_SIZE, + .pnum = &n, + .map = &map, .file = file, .done = false, }; @@ -2069,7 +2083,13 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, bdrv_coroutine_enter(bs, co); BDRV_POLL_WHILE(bs, !data.done); } - return data.ret; + if (data.ret < 0) { + *pnum = 0; + return data.ret; + } + assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); + *pnum = n >> BDRV_SECTOR_BITS; + return data.ret | map; } int64_t bdrv_get_block_status_above(BlockDriverState *bs, |