diff options
| author | Andy Pan <i@andypan.me> | 2024-08-06 16:36:45 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-08-07 17:28:44 +0000 |
| commit | 80746f7f2d4b3d1d2ea62878e7c89f5c6c3c2a2a (patch) | |
| tree | 3ecabc9154131e5e4d22538f4ddd35b402b59a85 /src/syscall/syscall_linux.go | |
| parent | b696250e5f0dcc4cfa863309538c65d30d2ad480 (diff) | |
| download | go-80746f7f2d4b3d1d2ea62878e7c89f5c6c3c2a2a.tar.xz | |
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 <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/syscall/syscall_linux.go')
0 files changed, 0 insertions, 0 deletions
