On Wed, Jan 17, 2018 at 04:38:04PM -0600, Eric Blake wrote:
> +/* Zero data. */
> +static int
> +delay_zero (struct nbdkit_next *next, void *nxdata,
> + void *handle, uint32_t count, uint64_t offset, int may_trim)
> +{
> + write_delay ();
> + return next->zero (nxdata, count, offset, may_trim);
If next->zero() fails with EOPNOTSUPP, that means we will delay once in
trying the underlying command, and again for each iteration of the
fallback loop as it calls delay_pwrite(). Is that okay, or do we want
to reproduce some fallback logic here and directly call next->pwrite on
EOPNOTSUPP so as to only have a single write delay in that case?
Good point. How about this, it seems simpler:
static int
delay_zero (struct nbdkit_next *next, void *nxdata,
void *handle, uint32_t count, uint64_t offset, int may_trim)
{
int r = next->zero (nxdata, count, offset, may_trim);
if (r != -1)
write_delay ();
return r;
}
And the same for the other methods in that filter.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org