On Sun, Aug 19, 2018 at 2:35 PM Richard W.M. Jones <rjones@redhat.com> wrote:
On Sun, Aug 19, 2018 at 01:13:05AM +0300, Nir Soffer wrote:
> When using file systems not supporting ZERO_RANGE (e.g. NFS 4.2) or
> block device on kernel < 4.9, we used to call fallocate() for every
> zero, fail with EOPNOTSUPP, and fallback to manual zeroing.  When
> trimming, we used to try unsupported fallocate() on every call.
>
> Change file handle to remember if punching holes or zeroing range are
> supported, and avoid unsupported calls.
>
> - zero changed to:
>   1. If we can punch hole and may trim, try PUNCH_HOLE
>   2. If we can zero range, try ZERO_RANGE
>   3. Fall back to manual writing
>
> - trim changed to:
>   1. If we can punch hole, try PUNCH_HOLE
>   2. Succeed
> ---
>  plugins/file/file.c | 80 ++++++++++++++++++++++++++++++---------------
>  1 file changed, 53 insertions(+), 27 deletions(-)
>
> diff --git a/plugins/file/file.c b/plugins/file/file.c
> index 3bb4d17..5daab63 100644
> --- a/plugins/file/file.c
> +++ b/plugins/file/file.c
> @@ -33,6 +33,7 @@

>  #include <config.h>

> +#include <stdbool.h>
>  #include <stdio.h>
>  #include <stdlib.h>

Can you put stdbook after stdlib for consistency with the
other source files.

Sure.
 

>  #ifdef FALLOC_FL_ZERO_RANGE
> -  r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);
> -  if (r == -1 && errno != EOPNOTSUPP) {
> -    nbdkit_error ("zero: %m");
> +  if (h->can_zero_range) {
> +    r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count);
> +    if (r== 0)

Spacing.

I think Eric comments on the same, line, but I don't see any spacing issue.
Can you explain where is the issue?
 

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