diff options
author | Kevin Wolf <kwolf@redhat.com> | 2012-03-20 15:12:58 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-04-20 15:57:30 +0200 |
commit | 621f058940ea9f1ef3d8774ef3203544f1228df1 (patch) | |
tree | bb1d8a76f9d7d737502e6daf68c143420454e3bc /block.c | |
parent | ab3a32ad5ea841c313e5f9c5f0d4ec02a8e9ddfc (diff) |
qcow2: Zero write support
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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 */ |