mirror of https://github.com/proxmox/mirror_qemu
cow: use bdrv_co_is_allocated()
Now that bdrv_co_is_allocated() is available we can use it instead of the synchronous bdrv_is_allocated() interface. This is a follow-up that Kevin Wolf <kwolf@redhat.com> pointed out after applying the series that introduces bdrv_co_is_allocated(). It is safe to make cow_read() a coroutine_fn because its only caller is a coroutine_fn. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>master
parent
fb0490f69f
commit
e94d138733
|
@ -171,14 +171,14 @@ static int cow_update_bitmap(BlockDriverState *bs, int64_t sector_num,
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cow_read(BlockDriverState *bs, int64_t sector_num,
|
static int coroutine_fn cow_read(BlockDriverState *bs, int64_t sector_num,
|
||||||
uint8_t *buf, int nb_sectors)
|
uint8_t *buf, int nb_sectors)
|
||||||
{
|
{
|
||||||
BDRVCowState *s = bs->opaque;
|
BDRVCowState *s = bs->opaque;
|
||||||
int ret, n;
|
int ret, n;
|
||||||
|
|
||||||
while (nb_sectors > 0) {
|
while (nb_sectors > 0) {
|
||||||
if (bdrv_is_allocated(bs, sector_num, nb_sectors, &n)) {
|
if (bdrv_co_is_allocated(bs, sector_num, nb_sectors, &n)) {
|
||||||
ret = bdrv_pread(bs->file,
|
ret = bdrv_pread(bs->file,
|
||||||
s->cow_sectors_offset + sector_num * 512,
|
s->cow_sectors_offset + sector_num * 512,
|
||||||
buf, n * 512);
|
buf, n * 512);
|
||||||
|
|
Loading…
Reference in New Issue