Don't use trim() for zeroing. NBD_CMD_TRIM does not guarantee anything
about the content of the trimmed range. Add allocate flag to zero(), so
it can be used both for sparse and allocated copy.
The zero strategy was less advanced than what we have in nbdkit file
plugin. Port the zero strategy from the file plugin, improving
reliability and compatibility.
Tested with loop devices, local files, and qemu-nbd.
Changes in v2:
- Rebase after struct rw refactoring
- Fix block device checks
- Improve formatting (Rich)
Changes in v3:
- Remvoe trim support, which also fix the compilation (v1 and v2 were
broken, I forgot to add the allocate flag to pipe-ops.c).
- Remove block device fix (already in master)
Nir Soffer (2):
copy: Do not use trim for zeroing
copy/file-ops.c: Port zero strategy from nbdkit
copy/copy-sparse.sh | 66 +++++++-------
copy/file-ops.c | 168 ++++++++++++++++++++++++++----------
copy/multi-thread-copying.c | 24 ++----
copy/nbd-ops.c | 51 ++---------
copy/nbdcopy.h | 20 ++---
copy/null-ops.c | 28 +-----
copy/pipe-ops.c | 12 ++-
copy/synch-copying.c | 8 +-
8 files changed, 190 insertions(+), 187 deletions(-)
--
2.26.2