The Friday 07 Mar 2014 à 23:55:50 (+0100), Max Reitz wrote :
> Add passthrough functions for bdrv_aio_discard(),
> bdrv_co_write_zeroes(), bdrv_truncate() and bdrv_has_zero_init().
>
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
> block/json.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/block/json.c b/block/json.c
> index f40343e..e4cdb68 100644
> --- a/block/json.c
> +++ b/block/json.c
> @@ -95,6 +95,21 @@ static BlockDriverAIOCB *json_aio_flush(BlockDriverState
> *bs,
> return bdrv_aio_flush(bs->file, cb, opaque);
> }
>
> +static BlockDriverAIOCB *json_aio_discard(BlockDriverState *bs,
> + int64_t sector_num, int nb_sectors,
> + BlockDriverCompletionFunc *cb,
> + void *opaque)
> +{
> + return bdrv_aio_discard(bs->file, sector_num, nb_sectors, cb, opaque);
> +}
> +
> +static coroutine_fn int json_co_write_zeroes(BlockDriverState *bs,
> + int64_t sector_num, int
> nb_sectors,
> + BdrvRequestFlags flags)
> +{
> + return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors, flags);
> +}
> +
> static void json_invalidate_cache(BlockDriverState *bs)
> {
> return bdrv_invalidate_cache(bs->file);
> @@ -105,6 +120,16 @@ static int64_t json_getlength(BlockDriverState *bs)
> return bdrv_getlength(bs->file);
> }
>
> +static int json_truncate(BlockDriverState *bs, int64_t offset)
> +{
> + return bdrv_truncate(bs->file, offset);
> +}
> +
> +static int json_has_zero_init(BlockDriverState *bs)
> +{
> + return bdrv_has_zero_init(bs->file);
> +}
> +
> static int json_refresh_limits(BlockDriverState *bs)
> {
> bs->bl = bs->file->bl;
> @@ -128,12 +153,17 @@ static BlockDriver bdrv_json = {
> .bdrv_aio_readv = json_aio_readv,
> .bdrv_aio_writev = json_aio_writev,
> .bdrv_aio_flush = json_aio_flush,
> + .bdrv_aio_discard = json_aio_discard,
> +
> + .bdrv_co_write_zeroes = json_co_write_zeroes,
>
> .bdrv_invalidate_cache = json_invalidate_cache,
>
> .has_variable_length = true,
> .bdrv_getlength = json_getlength,
> + .bdrv_truncate = json_truncate,
>
> + .bdrv_has_zero_init = json_has_zero_init,
> .bdrv_refresh_limits = json_refresh_limits,
> .bdrv_get_info = json_get_info,
>
> --
> 1.9.0
>
Reviewed-by: Benoit Canet <ben...@irqsave.net>