diff options
Diffstat (limited to 'block/io.c')
-rw-r--r-- | block/io.c | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/block/io.c b/block/io.c index 61b3477cd1..e64b1cb294 100644 --- a/block/io.c +++ b/block/io.c @@ -2016,7 +2016,7 @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, return ret; } -/* Coroutine wrapper for bdrv_get_block_status_above() */ +/* Coroutine wrapper for bdrv_block_status_above() */ static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) { BdrvCoBlockStatusData *data = opaque; @@ -2064,58 +2064,19 @@ static int bdrv_common_block_status_above(BlockDriverState *bs, return data.ret; } -int64_t bdrv_get_block_status_above(BlockDriverState *bs, - BlockDriverState *base, - int64_t sector_num, - int nb_sectors, int *pnum, - BlockDriverState **file) +int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, + int64_t offset, int64_t bytes, int64_t *pnum, + int64_t *map, BlockDriverState **file) { - int64_t ret; - int64_t n; - int64_t map; - - ret = bdrv_common_block_status_above(bs, base, true, - sector_num * BDRV_SECTOR_SIZE, - nb_sectors * BDRV_SECTOR_SIZE, - &n, &map, file); - if (ret < 0) { - *pnum = 0; - return ret; - } - assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); - *pnum = n >> BDRV_SECTOR_BITS; - return ret | map; + return bdrv_common_block_status_above(bs, base, true, offset, bytes, + pnum, map, file); } int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file) { - int64_t ret; - int n; - - assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); - assert(pnum); - /* - * The contract allows us to return pnum smaller than bytes, even - * if the next query would see the same status; we truncate the - * request to avoid overflowing the driver's 32-bit interface. - */ - bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); - ret = bdrv_get_block_status_above(bs, backing_bs(bs), - offset >> BDRV_SECTOR_BITS, - bytes >> BDRV_SECTOR_BITS, &n, file); - if (ret < 0) { - assert(INT_MIN <= ret); - *pnum = 0; - return ret; - } - *pnum = n * BDRV_SECTOR_SIZE; - if (map) { - *map = ret & BDRV_BLOCK_OFFSET_MASK; - } else { - ret &= ~BDRV_BLOCK_OFFSET_VALID; - } - return ret & ~BDRV_BLOCK_OFFSET_MASK; + return bdrv_block_status_above(bs, backing_bs(bs), + offset, bytes, pnum, map, file); } int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, |