[Libguestfs] [PATCH libnbd 2/2] examples: copy-libev.c: Simple sparsifying

Nir Soffer nsoffer at redhat.com
Fri Mar 5 19:45:42 UTC 2021


On Fri, Mar 5, 2021, 21:33 Eric Blake <eblake at 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 at 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20210305/38836a9d/attachment.htm>


More information about the Libguestfs mailing list