RFR: 8292562: (fc) Use copy_file_range in FileChannel::transferTo on Linux

Brian Burkhalter bpb at openjdk.org
Fri Aug 19 22:09:10 UTC 2022


On Fri, 19 Aug 2022 20:22:31 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>>> Given https://bugs.openjdk.org/browse/JDK-4950302 I suppose the existing code(`sendfile`) will fail as well but I'll check.
>> 
>> I'm pretty sure that sendfile64 will succeed but copy_file_range will fail. It may be that we have to add test for this scenario.
>
>> I'm pretty sure that sendfile64 will succeed but copy_file_range will fail. It may be that we have to add test for this scenario.
> 
> I will check both cases and probably add testing as there appears not to be any at present.

You are correct: `sendfile` succeeds but `copy_file_range` fails with `EBADF` when the destination is appending. I put in a fix for this in the source not to use `copy_file_range` if the target is open for appending. An alternative would be to just ignore `EBADF` if it occurred.

I will add a test next week.

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

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


More information about the nio-dev mailing list