[Libguestfs] nbdkit background threads
Richard W.M. Jones
rjones at redhat.com
Tue Feb 11 08:41:54 UTC 2020
On Mon, Feb 10, 2020 at 01:52:25PM -0600, Eric Blake wrote:
> On 2/10/20 1:39 PM, Richard W.M. Jones wrote:
> >https://github.com/libguestfs/nbdkit/blob/ecef5b16359fb5af7e7abf4fd2fb3ad5438b16be/TODO#L76
> >
> >Already existing filters (readahead, cache) could be improved if
> >filters could open a background work thread or threads which connect
> >independently to the plugin. A proposed new filter (scan) cannot
> >really be written at all without this capability.
> >
> >First of all the reason this can't be done today is because filters
> >are called with a next_ops structure which is only valid transiently
> >during the filter callback. It cannot safely be saved or passed to
> >another thread.
> >(https://github.com/libguestfs/nbdkit/blob/master/docs/nbdkit-filter.pod#next-plugin)
>
> I was independently thinking of fixing this: we want next_ops to be
> have a life equal to the connection itself, rather than
> stack-allocated. I'm hoping to post a patch for that shortly, as
> part of my experimentation with implementing ext2 as a filter
> instead of a plugin, where ext2 has the limitation that when writing
> a custom io_manager, you only get ONE spot where you can pass in an
> opaque pointer: our .prepare will have to pass a long-lived nxdata
> to ext2fs_open().
Yes I can see this could be tricky, especially in the presence of
multiple threads serving a single connection. The only alternative
way I can think to do it would be to use a pointer in thread-local
storage which would would update with next_ops / nxdata each time.
Do you have a preliminary patch for this yet, or do you want me to
look at it today?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
More information about the Libguestfs
mailing list