mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
qcow2: Zero write support
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
ab3a32ad5e
commit
621f058940
4 changed files with 105 additions and 3 deletions
14
block.c
14
block.c
|
@ -80,6 +80,8 @@ static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
|
|||
void *opaque,
|
||||
bool is_write);
|
||||
static void coroutine_fn bdrv_co_do_rw(void *opaque);
|
||||
static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors);
|
||||
|
||||
static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors,
|
||||
bool is_write, double elapsed_time, uint64_t *wait);
|
||||
|
@ -1708,8 +1710,8 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
|
|||
|
||||
if (drv->bdrv_co_write_zeroes &&
|
||||
buffer_is_zero(bounce_buffer, iov.iov_len)) {
|
||||
ret = drv->bdrv_co_write_zeroes(bs, cluster_sector_num,
|
||||
cluster_nb_sectors);
|
||||
ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,
|
||||
cluster_nb_sectors);
|
||||
} else {
|
||||
ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors,
|
||||
&bounce_qiov);
|
||||
|
@ -1819,9 +1821,15 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
|
|||
struct iovec iov;
|
||||
int ret;
|
||||
|
||||
/* TODO Emulate only part of misaligned requests instead of letting block
|
||||
* drivers return -ENOTSUP and emulate everything */
|
||||
|
||||
/* First try the efficient write zeroes operation */
|
||||
if (drv->bdrv_co_write_zeroes) {
|
||||
return drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors);
|
||||
ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors);
|
||||
if (ret != -ENOTSUP) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fall back to bounce buffer if write zeroes is unsupported */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue