Disbaling pread initialization is atually measurable and gives small speedup in
nbdcopy and some examples.
Some cases are safer; in copy-libev example, we allocate all buffers with
calloc() and resuse them for the entire copy, so the initialization is
completly useless.
In nbdcopy and Go aio_copy example, we allocate new buffer using malloc(), so
when working with bad server that does not return all data chunks in structured
reply, we can leak uninitialized memory to the destination server. I think this
issue should be solved by libnbd; it should verfify that the server return all
the expected chunks and fail the request if not.
Nir Soffer (3):
golang: examples: Do not initialize pread buffer
examples: copy-libev: Do not initialize pread buffer
copy: Do not initialize read buffer
copy/nbd-ops.c | 1 +
examples/copy-libev.c | 6 ++++++
golang/examples/aio_copy/aio_copy.go | 5 +++++
golang/examples/simple_copy/simple_copy.go | 5 +++++
4 files changed, 17 insertions(+)
--
2.35.1