Signed-off-by: Peter Lieven <p...@kamp.de> --- block-migration.c | 2 +- block.c | 20 +++++++++++--------- block/backup.c | 3 ++- block/qcow2-cluster.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 3 ++- block/raw_bsd.c | 5 +++-- block/vmdk.c | 3 ++- include/block/block.h | 4 ++-- include/block/block_int.h | 2 +- qemu-io-cmds.c | 2 +- 11 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/block-migration.c b/block-migration.c index daf9ec1..713a8e3 100644 --- a/block-migration.c +++ b/block-migration.c @@ -780,7 +780,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) } if (flags & BLK_MIG_FLAG_ZERO_BLOCK) { - ret = bdrv_write_zeroes(bs, addr, nr_sectors); + ret = bdrv_write_zeroes(bs, addr, nr_sectors, 0); } else { buf = g_malloc(BLOCK_SIZE); qemu_get_buffer(f, buf, BLOCK_SIZE); diff --git a/block.c b/block.c index 8eefb97..c453ec1 100644 --- a/block.c +++ b/block.c @@ -79,7 +79,7 @@ static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs, 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); + int64_t sector_num, int nb_sectors, BdrvRequestFlags flags); static QTAILQ_HEAD(, BlockDriverState) bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states); @@ -2391,10 +2391,11 @@ int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov) return bdrv_rwv_co(bs, sector_num, qiov, true, 0); } -int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) +int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, BdrvRequestFlags flags) { return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true, - BDRV_REQ_ZERO_WRITE); + BDRV_REQ_ZERO_WRITE | flags); } int bdrv_pread(BlockDriverState *bs, int64_t offset, @@ -2576,7 +2577,7 @@ 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 = bdrv_co_do_write_zeroes(bs, cluster_sector_num, - cluster_nb_sectors); + cluster_nb_sectors, 0); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. @@ -2710,7 +2711,7 @@ int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, } static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, - int64_t sector_num, int nb_sectors) + int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; QEMUIOVector qiov; @@ -2722,7 +2723,7 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, /* First try the efficient write zeroes operation */ if (drv->bdrv_co_write_zeroes) { - ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors); + ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors, flags); if (ret != -ENOTSUP) { return ret; } @@ -2777,7 +2778,7 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { - ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors); + ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags); } else { ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } @@ -2811,12 +2812,13 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, } int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, - int64_t sector_num, int nb_sectors) + int64_t sector_num, int nb_sectors, + BdrvRequestFlags flags) { trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors); return bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL, - BDRV_REQ_ZERO_WRITE); + BDRV_REQ_ZERO_WRITE | flags); } /** diff --git a/block/backup.c b/block/backup.c index 04c4b5c..5f6a642 100644 --- a/block/backup.c +++ b/block/backup.c @@ -138,7 +138,8 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, if (buffer_is_zero(iov.iov_base, iov.iov_len)) { ret = bdrv_co_write_zeroes(job->target, - start * BACKUP_SECTORS_PER_CLUSTER, n); + start * BACKUP_SECTORS_PER_CLUSTER, + n, 0); } else { ret = bdrv_co_writev(job->target, start * BACKUP_SECTORS_PER_CLUSTER, n, diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 738ff73..5215f5b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1601,7 +1601,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, } ret = bdrv_write_zeroes(bs->file, offset / BDRV_SECTOR_SIZE, - s->cluster_sectors); + s->cluster_sectors, 0); if (ret < 0) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); diff --git a/block/qcow2.c b/block/qcow2.c index 318d95d..6cb3e44 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1600,7 +1600,7 @@ static int qcow2_make_empty(BlockDriverState *bs) } static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs, - int64_t sector_num, int nb_sectors) + int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { int ret; BDRVQcowState *s = bs->opaque; diff --git a/block/qed.c b/block/qed.c index 6c0cba0..adc2736 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1397,7 +1397,8 @@ static void coroutine_fn qed_co_write_zeroes_cb(void *opaque, int ret) static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, - int nb_sectors) + int nb_sectors, + BdrvRequestFlags flags) { BlockDriverAIOCB *blockacb; BDRVQEDState *s = bs->opaque; diff --git a/block/raw_bsd.c b/block/raw_bsd.c index d4ace60..d5ab295 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -66,9 +66,10 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, } static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs, - int64_t sector_num, int nb_sectors) + int64_t sector_num, int nb_sectors, + BdrvRequestFlags flags) { - return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors); + return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors, flags); } static int coroutine_fn raw_co_discard(BlockDriverState *bs, diff --git a/block/vmdk.c b/block/vmdk.c index 96ef1b5..debf974 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1391,7 +1391,8 @@ static coroutine_fn int vmdk_co_write(BlockDriverState *bs, int64_t sector_num, static int coroutine_fn vmdk_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, - int nb_sectors) + int nb_sectors, + BdrvRequestFlags flags) { int ret; BDRVVmdkState *s = bs->opaque; diff --git a/include/block/block.h b/include/block/block.h index 9fb0c3d..47c6475 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -188,7 +188,7 @@ int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num, int bdrv_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, - int nb_sectors); + int nb_sectors, BdrvRequestFlags flags); int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov); int bdrv_pread(BlockDriverState *bs, int64_t offset, void *buf, int count); @@ -210,7 +210,7 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, * because it may allocate memory for the entire region. */ int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, - int nb_sectors); + int nb_sectors, BdrvRequestFlags flags); BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); int bdrv_get_backing_file_depth(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 3eeb6fe..56e1994 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -118,7 +118,7 @@ struct BlockDriver { * instead. */ int coroutine_fn (*bdrv_co_write_zeroes)(BlockDriverState *bs, - int64_t sector_num, int nb_sectors); + int64_t sector_num, int nb_sectors, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs, int64_t sector_num, int nb_sectors); int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs, diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 8565d49..66c0b9e 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -441,7 +441,7 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque) CoWriteZeroes *data = opaque; data->ret = bdrv_co_write_zeroes(data->bs, data->offset / BDRV_SECTOR_SIZE, - data->count / BDRV_SECTOR_SIZE); + data->count / BDRV_SECTOR_SIZE, 0); data->done = true; if (data->ret < 0) { *data->total = data->ret; -- 1.7.9.5