RFR: 8292562: (fc) Use copy_file_range in FileChannel::transferTo on Linux
Brian Burkhalter
bpb at openjdk.org
Fri Aug 19 15:27:49 UTC 2022
On Fri, 19 Aug 2022 06:42:08 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Add `copy_file_range(2)` to the native Linux implementation of `FileChannel::transferTo`.
>
> src/java.base/unix/native/libnio/ch/FileChannelImpl.c line 186:
>
>> 184: switch (errno) {
>> 185: case EINTR:
>> 186: case EINVAL:
>
> For EINVAL we could return IOS_INTERRUPTED if you want.
Did you intend `EINTR`?
> src/java.base/unix/native/libnio/ch/FileChannelImpl.c line 192:
>
>> 190: default:
>> 191: JNU_ThrowIOExceptionWithLastError(env, "Copy failed");
>> 192: return IOS_THROWN;
>
> Would you mind checking if we have tests that exercise transferTo when the target WritableByteChannel is to a file opened in append mode? Asking because copy_file_range will fall and I'm wondering what the existing behavior is.
Given https://bugs.openjdk.org/browse/JDK-4950302 I suppose the existing code(`sendfile`) will fail as well but I'll check.
-------------
PR: https://git.openjdk.org/jdk/pull/9925
More information about the nio-dev
mailing list