So I had a think about this.
Isn't this easier/better solved by lifting the 32 bit restriction on
the size of certain non-data requests (ie. NBD_CMD_BLOCK_STATUS,
NBD_CMD_TRIM, NBD_CMD_WRITE_ZEROES). The client can then query the
disk efficiently to see if it starts as zeroes, and can decide on the
basis of that whether it needs to "infill" zeroes as it goes along, or
can ignore zeroes because they are already zero.
While at the same time lifting this restriction also solves other
problems we have, notably the 32 bit limitation on trims which affects
large mkfs greatly.
Previously discussed here:
https://lists.debian.org/nbd/2018/09/msg00001.html
& continuing the next month here:
https://lists.debian.org/nbd/2018/10/msg00000.html
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html