[Libguestfs] [PATCH nbdkit] server: Implement extents/can_extents calls for plugins and filters.

Eric Blake eblake at redhat.com
Tue Mar 12 13:32:14 UTC 2019


On 3/12/19 8:13 AM, Richard W.M. Jones wrote:

> In the second case a concrete implementation might look like
> this (without error checking):
> 
>    /* plugin method */
>    int extents (void *handle, uint32_t count, uint64_t offset, uint32_t flags,
>                 void *extents_h)
>    {
>      nbdkit_extent_add (extents_h, offset, count, NBDKIT_EXTENT_TYPE_DATA);
>      nbdkit_extent_add (extents_h, offset+count, 1024, NBDKIT_EXTENT_TYPE_HOLE);
>      return 0;
>    }

This makes extents_h serve as the cookie or handle that groups all calls
from this particular .extents, distinct from any other .extents callback
that may be running in some other thread in parallel.  Looks good.

> 
>    /* filter method */
>    int extents (struct nbdkit_next_ops *next_ops, void *nxdata,
>                 void *handle, uint32_t count, uint64_t offset, uint32_t flags,
>                 void *extents_h, int *err)
>    {
>       if (next_ops->extents (...) == -1) return -1;
>       /* call adjust_offset_fn on each extent */
>       nbdkit_extent_foreach (extents_h, adjust_offset_fn);

Also seems useful. And if the filter adds padding, it could also call
nbdkit_extent_add, either before or after the nbdkit_extent_foreach call
(but more commonly after), to provide further details about the padding
it provides beyond what the underlying plugin was able to answer about.

> 
> If you think that looks reasonable I'll see if I can come up with an
> actual patch for this this afternoon.
> 

Sounds good to me.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190312/f671eeb2/attachment.sig>


More information about the Libguestfs mailing list