plugins: Add callback for writing zeroes
commit19184d3eb6356ae3b14da0fbaa9c9bdc7743a448
authorEric Blake <eblake@redhat.com>
Fri, 20 Jan 2017 20:16:20 +0000 (20 14:16 -0600)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 21 Jan 2017 14:43:49 +0000 (21 14:43 +0000)
treed18f1486fe28afc4601a35ffd4bc471c3d1890c8
parentdd621a964e3cbdaf93504d57ba57cc6f3c4b8892
plugins: Add callback for writing zeroes

Similar to .trim, except that it guarantees that zeroes are read
back, and also clients must obey the may_trim argument with
regards to whether a hole may be used or whether the file must
remain allocated with actual zeroes written.  If the callback is
not implemented, or if the callback fails with EOPNOTSUPP, fall
back to fragmenting the request and calling .pwrite with a
known-zero buffer.

The handling of EOPNOTSUPP allows callbacks to avoid the need
to reimplement the work of allocating an all-zero buffer; at least
the file driver on Linux will benefit from these semantics as it
means we can try to use fallocate(), then gracefully use normal
writes if the underlying file system doesn't support what we need.

Signed-off-by: Eric Blake <eblake@redhat.com>
docs/nbdkit-plugin.pod
include/nbdkit-plugin.h
src/internal.h
src/plugins.c