Skip to content

Commit 385b6a1

Browse files
panjf2000pull[bot]
authored andcommitted
os: employ sendfile(2) for file-to-file copying on Linux when needed
Go utilizes copy_file_range(2) for file-to-file copying only on kernel 5.3+, but even on 5.3+ this system call can still go wrong for some reason (check out the comment inside poll.CopyFileRange). Before Linux 2.6.33, out_fd must refer to a socket, but since Linux 2.6.33 it can be any file. Thus, we can employ sendfile(2) for copy between files when copy_file_range(2) fails to handle the copy, that way we can still benefit from the zero-copy technique on kernel <5.3 and wherever copy_file_range(2) is available but broken. Change-Id: I3922218c95ad34ee649ccdf3ccfbd1ce692bebcc Reviewed-on: https://go-review.googlesource.com/c/go/+/603295 Reviewed-by: David Chase <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent e85cd4f commit 385b6a1

File tree

3 files changed

+312
-205
lines changed

3 files changed

+312
-205
lines changed

0 commit comments

Comments
 (0)