summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-02-21 23:00:01 +0000
committerIan Lance Taylor <iant@google.com>2023-02-22 20:35:23 +0000
commit1acd39cc92cea4937fe9530c7d9bbce4711fc41c (patch)
treee4ff983f250e0dc12439862a927b221dabe3f809
parent7b398b1ff7d751032ea1e4ffed6f02675fc51c3b (diff)
downloadgo-git-1acd39cc92cea4937fe9530c7d9bbce4711fc41c.tar.gz
[release-branch.go1.20] Revert "internal/poll: drop redundant ENOSYS in CopyFileRange"
This reverts CL 428555. Reason for revert: It appears that even a newer kernel can get ENOSYS from copy_file_range. For #58592 Fixes #58627 Change-Id: Ib8dd1be61544f54bf652a99dc0b449109f8f50ed Reviewed-on: https://go-review.googlesource.com/c/go/+/470316 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--src/internal/poll/copy_file_range_linux.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/internal/poll/copy_file_range_linux.go b/src/internal/poll/copy_file_range_linux.go
index 66408e4590..ba33f5145d 100644
--- a/src/internal/poll/copy_file_range_linux.go
+++ b/src/internal/poll/copy_file_range_linux.go
@@ -41,18 +41,22 @@ func CopyFileRange(dst, src *FD, remain int64) (written int64, handled bool, err
}
n, err := copyFileRange(dst, src, int(max))
switch err {
+ case syscall.ENOSYS:
+ // copy_file_range(2) was introduced in Linux 4.5.
+ // Go supports Linux >= 2.6.33, so the system call
+ // may not be present.
+ //
+ // If we see ENOSYS, we have certainly not transferred
+ // any data, so we can tell the caller that we
+ // couldn't handle the transfer and let them fall
+ // back to more generic code.
+ return 0, false, nil
case syscall.EXDEV, syscall.EINVAL, syscall.EIO, syscall.EOPNOTSUPP, syscall.EPERM:
// Prior to Linux 5.3, it was not possible to
- // copy_file_range across file systems. An attempt
- // to do this will result in a EXDEV error.
- //
- // Even though we have checked the kernel version and blocked
- // the attempts to copy_file_range(2) when the kernel version
- // is older than 5.3, but until now the latest kernel (5.19.x)
- // may still return EXDEV error in certain cases.
- //
- // If we see EXDEV, we have not transferred any data,
- // and we can let the caller fall back to generic code.
+ // copy_file_range across file systems. Similarly to
+ // the ENOSYS case above, if we see EXDEV, we have
+ // not transferred any data, and we can let the caller
+ // fall back to generic code.
//
// As for EINVAL, that is what we see if, for example,
// dst or src refer to a pipe rather than a regular