-
Notifications
You must be signed in to change notification settings - Fork 1.9k
copy_file_range: fix fallback when source create on same txg #15172
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
Conversation
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. Signed-off-by: Rob Norris <[email protected]>
@oromenahar whoops, I missed this in review, sorry 😕 |
Will check this evening :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix and adding the test case.
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 <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#15170 Closes openzfs#15172
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 <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#15170 Closes openzfs#15172
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 <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #15170 Closes #15172
Oh is this why our clone fails if it is too soon after creating a file? Just returns EAGAIN. I see both Linux and FreeBSD can call a generic copy_file implementation, but there is no such nice call in OsX. I can certainly do a copy of FreeBSD using |
Its safe, just slow. You might be able to return something to signal to the caller that a fallback is necessary. Before Linux 5.3 we didn't call the fallback directly, we'd return If not the kernel, your copy handoff/clone syscall might have a return that signals to the application to do it by hand (eg |
There is nothing in XNU's syscall, or VNOP_CLONE that will handle any fallback, just returns error all the way back to userland. It's a bit unattractive to have
Although, I see in cp/copyfile: So I can probably return
Is it? So if you create a 4g file, then call clonefile immediately, Linux&FreeBSD would copy another 4g. txg_sync would wait one txg, then actually clone it? Did we test this? I'm curious, just not sure i'm "I'll test it" curious :) |
OK so quick and dirty test: With:
Results in
The concern there is, why are they different sizes? Testing with return
So in the interest of being similar to upstream, I will return ENOTSUP. |
This makes it basically the same as
Looking at the I suspect your implementation is going to be extremely close to the Linux one. |
Ahh OK so large file ended up completing in txg, so the
That is from older file_cmds-272, the newer file_cmds-428 has the fallback. That went into macOS-14 (Sonoma) so, only the very latest version. All older macOS will just get error if the EAGAIN thing happens, and they have no way to know if it isn't supported, and not just a temporary error. Honestly, EAGAIN is better there, so users can tell the difference, and ENOTSUP on macOS-14 and above. |
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 <[email protected]> Reviewed-by: Kay Pedersen <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#15170 Closes openzfs#15172
Motivation and Context
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.
Fixes #15170
How Has This Been Tested?
New test added that fails before the change, passes after.
FreeBSD untested, but it has the same shape. The test suite will confirm it compiles.
Types of changes
Checklist:
Signed-off-by
.