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

cp failing sporadically due to EAGAIN being returned from copy_file_range #15170

Closed
Tobi29 opened this issue Aug 13, 2023 · 2 comments · Fixed by #15172
Closed

cp failing sporadically due to EAGAIN being returned from copy_file_range #15170

Tobi29 opened this issue Aug 13, 2023 · 2 comments · Fixed by #15172
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@Tobi29
Copy link

Tobi29 commented Aug 13, 2023

System information

Type Version/Name
Distribution Name Arch Linux
Distribution Version Rolling release
Kernel Version 6.4.9-zen1-1-zen
Architecture x86_64
OpenZFS Version 2.2.99-61_g8ce2eba9e6

Describe the problem you're observing

Copying files using e.g. cp occasionally fails, giving an error like cp: error copying 'file_a' to 'file_b': Resource temporarily unavailable.
This is caused by copy_file_range in zfs returning EAGAIN, something that seems to have been added in f21662d.
The man page for copy_file_range does not mention EAGAIN as a possible error and I cannot say how many other programs, beyond cp, also handle EAGAIN as a hard error in this case.
Switching to cp --reflink=never fixes the problem.

The end result of this is that many automation scripts, e.g. makepkg on Arch Linux, are unusable because of files, because they trigger this error very frequently.

Describe how to reproduce the problem

This example script triggers the issue almost every time:

#!/bin/bash

dd if=/dev/urandom of=file_a bs=4MiB count=1
cp file_a file_b
dd if=/dev/urandom of=file_a bs=4MiB count=1
cp file_a file_b

# just cleanup
rm file_a file_b

It is required to run these commands in very quick succession.

Include any warning/errors/backtraces from the system logs

The mentioned script would output:

1+0 records in
1+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.00903691 s, 464 MB/s
1+0 records in
1+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.00990963 s, 423 MB/s
cp: error copying 'file_a' to 'file_b': Resource temporarily unavailable

Nothing can be seen in dmesg.

@Tobi29 Tobi29 added the Type: Defect Incorrect behavior (e.g. crash, hang) label Aug 13, 2023
@rincebrain
Copy link
Contributor

@oromenahar

@oromenahar
Copy link
Contributor

Got an update on this, will be merged pretty fast.
Thanks for this issue.

behlendorf pushed a commit that referenced this issue Aug 15, 2023
In 019dea0 we removed the conversion from EAGAIN->EXDEV inside
zfs_clone_range(), but forgot to add a test for EAGAIN to the
copy_file_range() entry points to trigger fallback to a content copy.

This commit fixes that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #15170
Closes #15172
usaleem-ix pushed a commit to truenas/zfs that referenced this issue Aug 17, 2023
In 019dea0 we removed the conversion from EAGAIN->EXDEV inside
zfs_clone_range(), but forgot to add a test for EAGAIN to the
copy_file_range() entry points to trigger fallback to a content copy.

This commit fixes that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#15170
Closes openzfs#15172
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Aug 25, 2023
In 019dea0 we removed the conversion from EAGAIN->EXDEV inside
zfs_clone_range(), but forgot to add a test for EAGAIN to the
copy_file_range() entry points to trigger fallback to a content copy.

This commit fixes that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#15170
Closes openzfs#15172
behlendorf pushed a commit that referenced this issue Aug 25, 2023
In 019dea0 we removed the conversion from EAGAIN->EXDEV inside
zfs_clone_range(), but forgot to add a test for EAGAIN to the
copy_file_range() entry points to trigger fallback to a content copy.

This commit fixes that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #15170
Closes #15172
lundman pushed a commit to openzfsonwindows/openzfs that referenced this issue Dec 12, 2023
In 019dea0 we removed the conversion from EAGAIN->EXDEV inside
zfs_clone_range(), but forgot to add a test for EAGAIN to the
copy_file_range() entry points to trigger fallback to a content copy.

This commit fixes that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#15170
Closes openzfs#15172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants