Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workarounds for copy_file_range issues #75428

Merged
merged 3 commits into from
Sep 5, 2020

Conversation

the8472
Copy link
Member

@the8472 the8472 commented Aug 11, 2020

fixes #75387
fixes #75446

…ttemted on a NFS mount under RHEL/CentOS 7.

The syscall is supposed to return ENOSYS in most cases but when calling it on NFS it may leak through
EOPNOTSUPP even though that's supposed to be handled by the kernel and not returned to userspace.
Since it returns ENOSYS in some cases anyway this will trip the  HAS_COPY_FILE_RANGE
detection anyway, so treat EOPNOTSUPP as if it were a ENOSYS.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.8_release_notes/deprecated_functionality#the_literal_copy_file_range_literal_call_has_been_disabled_on_local_file_systems_and_in_nfs
https://bugzilla.redhat.com/show_bug.cgi?id=1783554
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 11, 2020
@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 12, 2020

📌 Commit 1316c78 has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2020
@bors
Copy link
Contributor

bors commented Aug 12, 2020

⌛ Testing commit 1316c78 with merge c0e06fb4d88cf4063d23e407c155a2096b4ac611...

@rust-log-analyzer
Copy link
Collaborator

Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@bors
Copy link
Contributor

bors commented Aug 12, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 12, 2020
@the8472
Copy link
Member Author

the8472 commented Aug 12, 2020

The bors error is not helpful, spurious failure?

… on file size

This solves several problems

- race conditions where a file is truncated while copying from it. if we blindly trusted
  the file size this would lead to an infinite loop
- proc files appearing empty to copy_file_range but not to read/write
  coreutils/coreutils@4b04a0c
- copy_file_range returning 0 for some filesystems (overlay? bind mounts?)
  inside docker, again leading to an infinite loop
@the8472 the8472 changed the title Workaround for copy_file_range spuriously returning EOPNOTSUPP on CentOS 7 Workarounds for copy_file_range issues Aug 14, 2020
@the8472
Copy link
Member Author

the8472 commented Aug 14, 2020

Updated to address an additional copy_file_range issue.

@the8472
Copy link
Member Author

the8472 commented Aug 14, 2020

ping @joshtriplett

let copy_result = if has_copy_file_range {
let bytes_to_copy = cmp::min(len - written, usize::MAX as u64) as usize;
let bytes_to_copy = cmp::min(max_len - written, usize::MAX as u64) as usize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to keep track of max_len - written accurately at this point? It's probably okay just to pass a large constant size on every call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It avoids overflowing an u64. Plus I want to reuse the code in #75272 which will require exact max sizes

@crlf0710 crlf0710 added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 4, 2020
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2020
@bors
Copy link
Contributor

bors commented Sep 5, 2020

⌛ Testing commit 4ddedd5 with merge 596b8ed70633bf181a3b8966fb235e91a67ae146...

@bors
Copy link
Contributor

bors commented Sep 5, 2020

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 5, 2020
@Dylan-DPC-zz
Copy link

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 5, 2020
…triplett

Workarounds for copy_file_range issues

fixes rust-lang#75387
fixes rust-lang#75446
@bors
Copy link
Contributor

bors commented Sep 5, 2020

⌛ Testing commit 4ddedd5 with merge f9b36230f023ae6f396f3cc4284cd41a0583b819...

@bors
Copy link
Contributor

bors commented Sep 5, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 5, 2020
@the8472
Copy link
Member Author

the8472 commented Sep 5, 2020

I don't see how linux-only code changes can make a mingw build fail. Doubly so when it's doc tests.

@nagisa
Copy link
Member

nagisa commented Sep 5, 2020

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2020
@bors
Copy link
Contributor

bors commented Sep 5, 2020

⌛ Testing commit 4ddedd5 with merge de921ab...

@bors
Copy link
Contributor

bors commented Sep 5, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: joshtriplett
Pushing de921ab to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 5, 2020
@bors bors merged commit de921ab into rust-lang:master Sep 5, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 5, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 10, 2020
implement better availability probing for copy_file_range

Followup to rust-lang#75428 (comment)

Previously syscall detection was overly pessimistic. Any attempt to copy to an immutable file (EPERM) would disable copy_file_range support for the whole process.

The change tries to copy_file_range on invalid file descriptors which will never run into the immutable file case and thus we can clearly distinguish syscall availability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fs::copy hangs on docker (Linux) std::fs::copy fails on NFS volumes on CentOS 7