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

unix/kernel_copy.rs: copy_file_range_candidate allows empty output files #114373

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

xstaticxgpx
Copy link
Contributor

This is for #114341

The meta.len() > 0 condition here is intended for inputs only, ie. when input is in the /proc filesystem as documented.

That inaccurately included empty output files which are then shunted to the sendfile() routine leading to higher than nescessary IO util in some cases, specifically with CoW filesystems like btrfs.

Simply, determine what is input or output given the passed boolean.

@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2023

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.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added 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. labels Aug 2, 2023
@rust-log-analyzer

This comment has been minimized.

@xstaticxgpx
Copy link
Contributor Author

Sanity checking myself here (see test.rs in the linked issue)

$ ~/git/rust-lang/rust/build/host/stage1/bin/rustc --version
rustc 1.73.0-dev
$ ~/git/rust-lang/rust/build/host/stage1/bin/rustc test.rs 
$ strace ./test >test.out
..
copy_file_range(-1, NULL, -1, NULL, 1, 0) = -1 EBADF (Bad file descriptor)
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 561840
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 0
..
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 561840
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 0
..
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 561840
copy_file_range(3, NULL, 1, NULL, 1073741824, 0) = 0
..
$ cat test{,,} >test.out.cat
$ md5sum test.out*
88014b954f88d8b90b4169198a82bf71  test.out
88014b954f88d8b90b4169198a82bf71  test.out.cat

This is for rust-lang#114341

The `meta.len() > 0` condition here is intended for inputs only,
ie. when input is in the `/proc` filesystem as documented.

That inaccurately included empty output files which are then shunted to
the sendfile() routine leading to higher than nescessary IO util in some
cases, specifically with CoW filesystems like btrfs.

Further, `NoneObtained` is not relevant in this context, so remove it.

Simply, determine what is input or output given the passed enum Unit.
@the8472
Copy link
Member

the8472 commented Aug 3, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 3, 2023

📌 Commit 2232fe8 has been approved by the8472

It is now in the queue for this repository.

@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 3, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 4, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#113534 (Forbid old-style `simd_shuffleN` intrinsics)
 - rust-lang#113999 (Specify macro is invalid in certain contexts)
 - rust-lang#114348 (Migrate GUI colors test to original CSS color format)
 - rust-lang#114373 (unix/kernel_copy.rs: copy_file_range_candidate allows empty output files)
 - rust-lang#114404 (Migrate GUI colors test to original CSS color format)
 - rust-lang#114409 (builtin impl confirmation wuhu)
 - rust-lang#114429 (compiletest: Handle non-utf8 paths (fix FIXME))
 - rust-lang#114431 (Enable tests on rustc_codegen_ssa)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 539fecb into rust-lang:master Aug 4, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants