<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Aug 19, 2018 at 2:35 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@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 Sun, Aug 19, 2018 at 01:13:05AM +0300, Nir Soffer wrote:<br>
> When using file systems not supporting ZERO_RANGE (e.g. NFS 4.2) or<br>
> block device on kernel < 4.9, we used to call fallocate() for every<br>
> zero, fail with EOPNOTSUPP, and fallback to manual zeroing.  When<br>
> trimming, we used to try unsupported fallocate() on every call.<br>
> <br>
> Change file handle to remember if punching holes or zeroing range are<br>
> supported, and avoid unsupported calls.<br>
> <br>
> - zero changed to:<br>
>   1. If we can punch hole and may trim, try PUNCH_HOLE<br>
>   2. If we can zero range, try ZERO_RANGE<br>
>   3. Fall back to manual writing<br>
> <br>
> - trim changed to:<br>
>   1. If we can punch hole, try PUNCH_HOLE<br>
>   2. Succeed<br>
> ---<br>
>  plugins/file/file.c | 80 ++++++++++++++++++++++++++++++---------------<br>
>  1 file changed, 53 insertions(+), 27 deletions(-)<br>
> <br>
> diff --git a/plugins/file/file.c b/plugins/file/file.c<br>
> index 3bb4d17..5daab63 100644<br>
> --- a/plugins/file/file.c<br>
> +++ b/plugins/file/file.c<br>
> @@ -33,6 +33,7 @@<br>
>  <br>
>  #include <config.h><br>
>  <br>
> +#include <stdbool.h><br>
>  #include <stdio.h><br>
>  #include <stdlib.h><br>
<br>
Can you put stdbook after stdlib for consistency with the<br>
other source files.<br></blockquote><div><br></div><div>Sure.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>  #ifdef FALLOC_FL_ZERO_RANGE<br>
> -  r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);<br>
> -  if (r == -1 && errno != EOPNOTSUPP) {<br>
> -    nbdkit_error ("zero: %m");<br>
> +  if (h->can_zero_range) {<br>
> +    r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);<br>
> +    if (r== 0)<br>
<br>
Spacing.<br></blockquote><div><br></div><div>I think Eric comments on the same, line, but I don't see any spacing issue.</div><div>Can you explain where is the issue?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Rich.<br>
<br>
-- <br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-builder quickly builds VMs from scratch<br>
<a href="http://libguestfs.org/virt-builder.1.html" rel="noreferrer" target="_blank">http://libguestfs.org/virt-builder.1.html</a><br>
</blockquote></div></div>