"Richard W.M. Jones" <[email protected]> writes:

> I don't have OpenZFS to test, but what seems to be happening on
> regular filesystems is we call truncate on the destination before
> doing the copy:
>
>   
> https://gitlab.com/nbdkit/libnbd/-/blob/6182a590ced685694574b74884c9cec53668f879/copy/main.c#L500
>
> which eventually calls fallocate with mode == 0 here:
>
>   
> https://gitlab.com/nbdkit/libnbd/-/blob/6182a590ced685694574b74884c9cec53668f879/copy/file-ops.c#L587
>
> Confirmed in strace:
>
>   2745865 ftruncate(4, 0)                 = 0
>   2745865 ftruncate(4, 33554432)          = 0
>   2745865 fallocate(4, 0, 0, 33554432)    = 0
>
> In Linux this is documented as:
>
>   Allocating disk space
>     The default operation (i.e., mode is zero) of fallocate() allocates  the
>     disk  space within the range specified by offset and len.  [...]
>
> which is the behaviour that we want here, allocating the space.  We
> make no further writes to the output disk in this test, but end up
> with a 32M fully allocated, zeroed disk (what we want).
>
> ZoL is probably ignoring fallocate and not allocating the space.  It
> may be returning ENOTSUP / EOPNOTSUPP, which we deliberately ignore.

FWIW, that does not appear to be the case:

  ~/tmp$ strace -e trace=ftruncate,fallocate truncate -s 33554432 
copy-allocated-destination-zero-synch.out
  ftruncate(3, 33554432)                  = 0
  +++ exited with 0 +++
  ~/tmp$ strace -e trace=ftruncate,fallocate truncate -r 
copy-allocated-destination-zero-synch.out 
copy-allocated-destination-zero-synch.inftruncate(3, 33554432)                  
= 0
  +++ exited with 0 +++
  ~/tmp$ strace -e trace=ftruncate,fallocate nbdcopy --allocated 
--destination-is-zero --synchronous --request-size=32K 
copy-allocated-destination-zero-synch.in 
copy-allocated-destination-zero-synch.out
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971755, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971757, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971758, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971761, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971764, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1971765, si_uid=0, 
si_status=0, si_utime=0, si_stime=0} ---
  ftruncate(4, 0)                         = 0
  ftruncate(4, 33554432)                  = 0
  fallocate(4, 0, 0, 33554432)            = 0
  +++ exited with 0 +++
  ~/tmp$ 
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Libguestfs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to