qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 02/17] block/io: use qemu_iovec_init_buf


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 02/17] block/io: use qemu_iovec_init_buf
Date: Thu, 7 Feb 2019 08:53:18 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 2/7/19 4:24 AM, Vladimir Sementsov-Ogievskiy wrote:
> Use new qemu_iovec_init_buf() instead of
> qemu_iovec_init_external( ... , 1), which simplifies the code.
> 
> While being here, use qemu_try_blockalign0 as well.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
>  block/io.c | 89 ++++++++++++------------------------------------------
>  1 file changed, 20 insertions(+), 69 deletions(-)
> 

> @@ -1477,7 +1456,7 @@ static int coroutine_fn 
> bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
>  {
>      BlockDriver *drv = bs->drv;
>      QEMUIOVector qiov;
> -    struct iovec iov = {0};
> +    void *buf = NULL;
>      int ret = 0;
>      bool need_flush = false;
>      int head = 0;
> @@ -1547,16 +1526,14 @@ static int coroutine_fn 
> bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
>                  need_flush = true;
>              }
>              num = MIN(num, max_transfer);
> -            iov.iov_len = num;
> -            if (iov.iov_base == NULL) {
> -                iov.iov_base = qemu_try_blockalign(bs, num);
> -                if (iov.iov_base == NULL) {
> +            if (buf == NULL) {
> +                buf = qemu_try_blockalign0(bs, num);
> +                if (buf == NULL) {
>                      ret = -ENOMEM;
>                      goto fail;
>                  }
> -                memset(iov.iov_base, 0, num);
>              }
> -            qemu_iovec_init_external(&qiov, &iov, 1);
> +            qemu_iovec_init_buf(&qiov, buf, num);

The use of qemu_try_blockalign0() is new to this revision, but fits in
well enough that I don't think you need to split the patch.

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]