mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
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>
This commit is contained in:
parent
2e8bc7874b
commit
4bcd936e47
1 changed files with 38 additions and 18 deletions
50
block/io.c
50
block/io.c
|
@ -1765,17 +1765,18 @@ int bdrv_flush_all(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct BdrvCoGetBlockStatusData {
|
typedef struct BdrvCoBlockStatusData {
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
BlockDriverState *base;
|
BlockDriverState *base;
|
||||||
bool want_zero;
|
bool want_zero;
|
||||||
int64_t sector_num;
|
int64_t offset;
|
||||||
int nb_sectors;
|
int64_t bytes;
|
||||||
int *pnum;
|
int64_t *pnum;
|
||||||
|
int64_t *map;
|
||||||
BlockDriverState **file;
|
BlockDriverState **file;
|
||||||
int64_t ret;
|
int ret;
|
||||||
bool done;
|
bool done;
|
||||||
} BdrvCoGetBlockStatusData;
|
} BdrvCoBlockStatusData;
|
||||||
|
|
||||||
int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
|
int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
|
||||||
int64_t sector_num,
|
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() */
|
/* Coroutine wrapper for bdrv_get_block_status_above() */
|
||||||
static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque)
|
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,
|
ret = bdrv_co_get_block_status_above(data->bs, data->base,
|
||||||
data->want_zero,
|
data->want_zero,
|
||||||
data->sector_num,
|
data->offset >> BDRV_SECTOR_BITS,
|
||||||
data->nb_sectors,
|
data->bytes >> BDRV_SECTOR_BITS,
|
||||||
data->pnum,
|
&n,
|
||||||
data->file);
|
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;
|
data->done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2049,13 +2060,16 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs,
|
||||||
BlockDriverState **file)
|
BlockDriverState **file)
|
||||||
{
|
{
|
||||||
Coroutine *co;
|
Coroutine *co;
|
||||||
BdrvCoGetBlockStatusData data = {
|
int64_t n;
|
||||||
|
int64_t map;
|
||||||
|
BdrvCoBlockStatusData data = {
|
||||||
.bs = bs,
|
.bs = bs,
|
||||||
.base = base,
|
.base = base,
|
||||||
.want_zero = want_zero,
|
.want_zero = want_zero,
|
||||||
.sector_num = sector_num,
|
.offset = sector_num * BDRV_SECTOR_SIZE,
|
||||||
.nb_sectors = nb_sectors,
|
.bytes = nb_sectors * BDRV_SECTOR_SIZE,
|
||||||
.pnum = pnum,
|
.pnum = &n,
|
||||||
|
.map = &map,
|
||||||
.file = file,
|
.file = file,
|
||||||
.done = false,
|
.done = false,
|
||||||
};
|
};
|
||||||
|
@ -2069,7 +2083,13 @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs,
|
||||||
bdrv_coroutine_enter(bs, co);
|
bdrv_coroutine_enter(bs, co);
|
||||||
BDRV_POLL_WHILE(bs, !data.done);
|
BDRV_POLL_WHILE(bs, !data.done);
|
||||||
}
|
}
|
||||||
|
if (data.ret < 0) {
|
||||||
|
*pnum = 0;
|
||||||
return data.ret;
|
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,
|
int64_t bdrv_get_block_status_above(BlockDriverState *bs,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue