<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Aug 13, 2018 at 8:52 PM Eric Blake <<a href="mailto:eblake@redhat.com">eblake@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 08/03/2018 02:28 PM, Nir Soffer wrote:<br>
> File systems not supporting FALLOC_FL_ZERO_RANGE yet fall back to manual<br>
> zeroing.<br>
> <br>
> We can avoid this by combining two fallocate calls:<br>
> <br>
>      fallocate(FALLOC_FL_PUNCH_HOLE)<br>
>      fallocate(0)<br>
> <br>
> Based on my tests this is much more efficient compared to manual<br>
> zeroing. The idea came from this qemu patch:<br>
> <a href="https://github.com/qemu/qemu/commit/1cdc3239f1bb" rel="noreferrer" target="_blank">https://github.com/qemu/qemu/commit/1cdc3239f1bb</a><br>
> <br>
<br>
> <br>
> Note: the image is sparse, but nbdkit creates a fully allocated image.<br>
> This may be a bug in nbdkit or qemu-img.<br>
<br>
Calling fallocate(0) forces allocation; so anything explicitly written <br>
to 0 won't be sparse when this mode is used.</blockquote><div><br></div><div>Sure, this is a poor mans replacement for ZERO_RANGE. I assume that</div><div>we want sparseness only when may_trim is set, which is the current</div><div>behavior before this patch.</div><div><br></div><div>With qemu-img the default is sparse, and using -o preallocation=falloc</div><div>make the image preallocated. It seems that we don't have a way to select</div><div>sparseness of the destination image in NBD, or maybe I'm missing something?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's also a question of <br>
whether your source file accurately reports holes to begin with (poor <br>
tmpfs SEEK_HOLE performance is still a common problem).  But I don't see <br>
that as getting in the way of this patch going in.<br></blockquote><div><br></div><div>Nir </div></div></div>