On 31/05/18 13:42, Goldwyn Rodrigues wrote: > This is a patch set to use copy_file_range() system call to copy > file from source to destination. The advantage is lower system time > because it avoids copy to and from userspace. > > In my tests, I am getting lower system times consumed while performing > with the copy_file_range.
When copy_file_range() was being proposed I asked for flags to control how sparse, unallocated, CoW regions were handled. I still see no flags defined in the latest man pages at least, so I don't think it's generally usable as is. It would be good to get confirmation as to how copy_file_range() currently deals with the 3 region types above. These cases were discussed previously at: https://lists.gnu.org/archive/html/coreutils/2015-09/msg00025.html In regard to reflinking, we might actually change to trying that by default in cp (mv already does it by default). The reason being that depending on file system, or physical device, you may not be actually getting an extra resiliency from a copy, as an actual copy is not guaranteed. Now that default change could have significant consequences, so it would be something that would be most appropriate in a major version change I think. For copy() in coreutils, we might do something like: if ((remote(dst) && remote(src)) || sparse_mode==SPARSE_NEVER || (sparse_mode!=SPARSE_ALWAYS && !is_sparse(src))) ok = copy_file_range() else ok = reflink() if (!ok) existing_copy() thanks! Pádraig
