Am 27.06.2013 um 15:11 hat Peter Lieven geschrieben:
> write zeroes is emulated by unmap if the target supports unmapping
> an unmapped blocks read as zero. this emulation is only done if the
> device was opened with BDRV_O_UNMAP and the request can be handled
> within a single request. a failback to writev is performed otherwise.
> 
> Signed-off-by: Peter Lieven <p...@kamp.de>
> ---
>  block/iscsi.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index d31ee95..92e66a6 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -928,6 +928,49 @@ fail:
>      return 0;
>  }
>  
> +static int
> +coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
> +                                   int nb_sectors)
> +{
> +    IscsiLun *iscsilun = bs->opaque;
> +    struct IscsiTask iTask;
> +    struct unmap_list list[1];

Why declare an array when it's only one element anyway?

> +    if (!iscsilun->lbprz || !iscsilun->lbpu || !(bs->open_flags & 
> BDRV_O_UNMAP) ||
> +        nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size > 
> iscsilun->max_unmap) {

The first part of this line is sector_qemu2lun().

> +        /* fall back to writev */
> +        return -ENOTSUP;
> +    }
> +
> +    iscsi_co_init_iscsitask(iscsilun, &iTask);
> +
> +    list[0].lba = sector_qemu2lun(sector_num, iscsilun);
> +    list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun->block_size;

Same here.

Kevin

Reply via email to