Is this theoretical or is there support for it already in the kernel and NFS daemons?
Reading the manpage for copy_file_range the notes section states:
copy_file_range() gives filesystems an opportunity to implement "copy
acceleration" techniques, such as the use of reflinks (i.e., two or
more inodes that share pointers to the same copy-on-write disk blocks)
or server-side-copy (in the case of NFS).
But doesn't mention if these techniques are actually used. I guess there's some help in future proofing your code.Edit: I tested this on my Ubuntu 20.04 machine and a 1GB file full of random data sitting in the file cache. Using copy_file_range I could make a local-local copy in 0.595 seconds on average. Using a primitive copy/write loop took 0.600 seconds. But these values are somewhat noisy and the difference is down in the error margin. It doesn't appear that my 5.4.0 kernel on ext4 is employing the reflinks optimization.