[Libguestfs] [nbdkit PATCH v3 0/5] Play with libnbd for nbdkit-nbd

Richard W.M. Jones rjones at redhat.com
Wed Jun 12 21:18:41 UTC 2019


On Wed, Jun 12, 2019 at 04:00:08PM -0500, Eric Blake wrote:
> libnbd-0.1.4-1 is now available in Fedora 29/30 updates testing.
> 
> Diffs since v2 - rebase to master, bump from libnbd 0.1.2 to 0.1.3+,
> add tests to TLS usage which flushed out the need to turn relative
> pathnames into absolute, doc tweaks
> 
> Now that the testsuite covers TLS and libnbd has been fixed to provide
> the things I found lacking when developing v2, I'm leaning towards
> pushing this on Monday, or sooner if I get a positive review.

This looks reasonable.

There's a slow-down, but we may be able to fix that with a concurrent
writer thread in future.

The pipe-to-self trick is interesting and comes back to the issue of
what is the thread model of libnbd.  If we think that libnbd shouldn't
create threads or do tricky Linux-specific stuff internally, then
asking callers to do this is reasonable.

If I understand how this works:

* There is one "reader" thread (per connection) which is doing polls.
  Essentially this is a background thread as far as nbdkit is
  concerned, not a thread that nbdkit has created or knows about.

* There is a pipe-to-self (per connection).  When a command is
  submitted from an nbdkit-managed thread a byte is sent down this
  pipe.

* The reader thread can either wake up because the socket is ready for
  read or write, or because of an indication on the pipe-to-self.

* If the socket is ready for read or write then the normal
  nbd_aio_notify_read|write function is called which will move the
  state machine along, and also check for command completion.

* If it's pipe-to-self indication then we will (after checking for
  command completion) check the direction flag again and reenter the
  poll.  The reason for this is because when the other thread started
  an AIO command it might have changed the handle state.

* The pipe ensures there is no race (I think).

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list