mirror of https://github.com/xemu-project/xemu.git
block: switch to co_wrapper for bdrv_is_allocated_*
Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20230904100306.156197-4-pbonzini@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
1b88457eaa
commit
578ffa9ffb
53
block/io.c
53
block/io.c
|
@ -2777,45 +2777,6 @@ int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t offset,
|
||||||
return !!(ret & BDRV_BLOCK_ALLOCATED);
|
return !!(ret & BDRV_BLOCK_ALLOCATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
|
||||||
int64_t *pnum)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
int64_t dummy;
|
|
||||||
IO_CODE();
|
|
||||||
|
|
||||||
ret = bdrv_common_block_status_above(bs, bs, true, false, offset,
|
|
||||||
bytes, pnum ? pnum : &dummy, NULL,
|
|
||||||
NULL, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return !!(ret & BDRV_BLOCK_ALLOCATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See bdrv_is_allocated_above for documentation */
|
|
||||||
int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
|
|
||||||
BlockDriverState *base,
|
|
||||||
bool include_base, int64_t offset,
|
|
||||||
int64_t bytes, int64_t *pnum)
|
|
||||||
{
|
|
||||||
int depth;
|
|
||||||
int ret;
|
|
||||||
IO_CODE();
|
|
||||||
|
|
||||||
ret = bdrv_co_common_block_status_above(top, base, include_base, false,
|
|
||||||
offset, bytes, pnum, NULL, NULL,
|
|
||||||
&depth);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret & BDRV_BLOCK_ALLOCATED) {
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
|
* Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
|
||||||
*
|
*
|
||||||
|
@ -2833,18 +2794,18 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
|
||||||
* words, the result is not necessarily the maximum possible range);
|
* words, the result is not necessarily the maximum possible range);
|
||||||
* but 'pnum' will only be 0 when end of file is reached.
|
* but 'pnum' will only be 0 when end of file is reached.
|
||||||
*/
|
*/
|
||||||
int bdrv_is_allocated_above(BlockDriverState *top,
|
int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *bs,
|
||||||
BlockDriverState *base,
|
BlockDriverState *base,
|
||||||
bool include_base, int64_t offset,
|
bool include_base, int64_t offset,
|
||||||
int64_t bytes, int64_t *pnum)
|
int64_t bytes, int64_t *pnum)
|
||||||
{
|
{
|
||||||
int depth;
|
int depth;
|
||||||
int ret;
|
int ret;
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
|
||||||
ret = bdrv_common_block_status_above(top, base, include_base, false,
|
ret = bdrv_co_common_block_status_above(bs, base, include_base, false,
|
||||||
offset, bytes, pnum, NULL, NULL,
|
offset, bytes, pnum, NULL, NULL,
|
||||||
&depth);
|
&depth);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,16 +147,18 @@ bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
|
||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
bdrv_co_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
bdrv_co_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||||
int64_t *pnum);
|
int64_t *pnum);
|
||||||
int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
int co_wrapper_mixed_bdrv_rdlock
|
||||||
int64_t *pnum);
|
bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
|
||||||
|
int64_t bytes, int64_t *pnum);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
bdrv_co_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
bdrv_co_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
||||||
bool include_base, int64_t offset, int64_t bytes,
|
bool include_base, int64_t offset, int64_t bytes,
|
||||||
int64_t *pnum);
|
int64_t *pnum);
|
||||||
int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
|
int co_wrapper_mixed_bdrv_rdlock
|
||||||
bool include_base, int64_t offset, int64_t bytes,
|
bdrv_is_allocated_above(BlockDriverState *bs, BlockDriverState *base,
|
||||||
int64_t *pnum);
|
bool include_base, int64_t offset,
|
||||||
|
int64_t bytes, int64_t *pnum);
|
||||||
|
|
||||||
int coroutine_fn GRAPH_RDLOCK
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset, int64_t bytes);
|
bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset, int64_t bytes);
|
||||||
|
|
Loading…
Reference in New Issue