On Thu, Mar 22, 2018 at 05:35:17PM -0500, Eric Blake wrote: > Originally, I thought that since the plugin always emulates > .zero with a fallback to .pwrite, we didn't need to expose the > backend's .can_zero to plugins. But there is another > consideration, as shown at least in the nbd plugin: a plugin > may implement a .zero callback that depends on support from > a remote endpoint. If the remote endpoint doesn't support > zeroes, then the plugin HAS to fail .zero with EOPNOTSUPP to > get the automatic fallback to .pwrite; this is slightly > wasteful to just telling nbdkit to not use the .zero callback > when it won't work. > > At the same time, we still want to advertise zero support to > the client, even if we won't be calling .zero, since handling > NBD_CMD_WRITE_ZEROES allows for less network traffic; if it > is ever truly necessary to avoid advertising to the guest, the > nozero filter can accomplish that task. > > So, this patch exposes a .can_zero callback for plugins, > which can usually be omitted, but which can be used to short- > circuit calls to .zero, with the nbd plugin as the first user; > while plugins.c continues to report true (well, the same result > as .can_write) to the backend regardless of the plugin's > answer, unless the plugin hits an error. > > Testing of the nbd changes (and thus of the general nbdkit > handling of plugin .can_zero) is best done as part of the > nozero filter: using the filter on the server side means the > nbd plugin won't see a zero advertisement, and thus the client > side does not call nbd's .zero, but still advertises zero to > the client. > > Now that the set of feature callbacks is the same for plugins > and filters, we can consolidate the documentation for filters > and merely focus on the slight differences. > > This patch breaks ABI from the earlier exposure of .can_fua to > plugins a few patches ago, but that is okay as there has not > been a release in the meantime (the logical grouping was nicer > this way). Had a release happened, .can_zero would have to > be placed after .zero in struct nbdkit_plugin. Also, in > plugins.c, rearrange get_error() to a more logical location. > > Signed-off-by: Eric Blake <[email protected]>
Yup, looks good, ACK. 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 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
