On Fri, Mar 5, 2021, 21:33 Eric Blake <eblake@redhat.com> wrote:
On 3/5/21 11:16 AM, Nir Soffer wrote:
> If a request includes only zeroes, use efficient zero method instead of
> sending the zeroes over the wire.
>
> Signed-off-by: Nir Soffer <nsoffer@redhat.com>
> ---
>  examples/Makefile.am  |  1 +
>  examples/copy-libev.c | 68 ++++++++++++++++++++++++++++++++++---------
>  2 files changed, 55 insertions(+), 14 deletions(-)
>

> +static void
> +start_zero(struct request *r)
> +{
> +    int64_t cookie;
> +
> +    DEBUG ("start zero offset=%ld len=%ld", r->offset, r->length);
> +
> +    cookie = nbd_aio_zero (
> +        dst.nbd, r->length, r->offset,
> +        (nbd_completion_callback) { .callback=request_completed,
> +                                    .user_data=r },
> +        0);
> +    if (cookie == -1)
> +        FAIL ("Cannot start zero: %s", nbd_get_error ());

You didn't check nbd_can_zero anywhere.  If the server does not
advertise support for NBD_CMD_ZERO (possible to do with nbdkit
--filter=nozero), then this will always fail.  It may be worth adding a
manual fallback to write in this case, instead of completely failing.

Right, should be easy to add.


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