I had a long think about all this today and I'm not really any closer
to knowing what the solution should be. However some observations,
mostly obvious:
* Storing the commands in linked lists probably won't work well when
we depend more and more on quickly looking them up by cookie number.
So we'll have to change the way they are stored, probably a simple
hash on the bottom bits of the cookie number is fine.
* If we break out the create command / submit command steps then we
will need a separate cmds_pending list (or hash) before commands are
added to cmds_to_issue.
* If we allow commands to be constructed in steps:
cookie = nbd_aio_pread (nbd, ...);
nbd_aio_add_callback (nbd, cookie, ...);
nbd_aio_set_autoretire (nbd,cookie, ...);
nbd_aio_submit (nbd, cookie);
then we end up having a whole lot more locking overhead which may
matter. This is an argument for more fine-grained locking perhaps.
* Also the API becomes a whole lot more complex to use and therefore
error-prone.
* At the moment we allow multiple callbacks in the Closure parameter.
But I think we won't need that, and can probably simplify the
generator to allow a single callback per Closure. Also that allows us
to have different scopes per callback (ie. persistent, one-shot, etc.)
in the same function. [You pointed this out in your email already]
* Maybe a case for adding an Optional (Closure ...) type to allow a
callback to be nullable. In Python & OCaml they are currently not
nullable. Unclear if they are or are supposed to be in C.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v