Add fallback for copy_file_range EXDEV error #3756
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3654
Add fallback to other copy routines in case of error in previous attempt.
I tried to keep it generic, but for now it targets
EXDEV
error incopy_file_range
explicitly.For efficiency sake, I kept the tiered approach to available kernel routines which was previously selected by compile flags.
To do the fallback in runtime I had to duplicate some code. The effort to refactor this went a bit above the scope of a bugfix. At least for now it keeps the change readily accessible for review.
Added some comments for the one trying to clean this up.
Functional changes:
Previously:
Try one of
copy_file_range
orsendfile64
in this order selected during compile time, if it fails exittr_sys_path_copy
Use user-space copy if neither was available during compile time
Now:
First try
copy_file_range
if available during compile time.Try
sendfile64
if available in case of previousEXDEV
or whencopy_file_range
wasn't available.Then try user-space copy if neither kernel routine was available during compile time or previous
EXDEV
errno was set