RFR: 8264744: (fs) Use file cloning in Linux and macOS versions of FileChannel transfer and Files copy methods [v2]

Alan Bateman alanb at openjdk.org
Fri Jul 15 10:16:02 UTC 2022


On Fri, 15 Jul 2022 02:30:00 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Add file cloning to `java.nio.channels.FileChannel::transferTo` and `java.nio.file.Files.copy(Path,Path)`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8264744: Refactor into provider+dispatcher to reduce amount of JNI code

This version looks much better but I think it will need another round of two to get the code into the right place. As it stands, the change mean that some of the macOS specific file copy code is in UnixCopyFile and the reset is in BsdNativeDispatcher. 

For macOS I suspect we'll end up with BsdCopyFile extending UnixCopyFile add adding support for fcopyfile and clonefile. Similarly LinuxCopyFile will extend UnixCopyFile and add support for copy_file_range.

A few specific issues on this version:
- LinuxFileSystemProvider.clone leaks a file descriptor if creating the target file fails
- LinuxFileSystemProvider.clone checks if the file exists but that check doesn't make sense here
- LinuxNativeDispatcher.ioctl_ficlone uses Blocker but I would have expected that in the caller, not here
- BsdFileSystemProvider.clone uses noFollowLinks. I think it would be clearer everywhere to invert that to followLinks. It may be better to map it to the flag at the Java level too.
- I wonder if FICLONE is available at build time to avoid the hardcoded value (main concern is whether it has the same value on all Linux ports)

-------------

PR: https://git.openjdk.org/jdk/pull/9486


More information about the nio-dev mailing list