-
Notifications
You must be signed in to change notification settings - Fork 262
pkg/fileutils: add LinkOrCopy() #2251
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
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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! I agree c/storage is the right place for this.
I wonder whether we want the “…OrCopy” part; it seems somewhat attractive to me to have drivers/copy.CopyRegularToFile
call this new function. (And there’s… friction: that function needs to explicitly implement doCopyWithFileRange
only because it relies on pools.Copy
, which defeats the equivalent of doCopyWithFileRange
inside the standard library.)
I think we can start with this …OrCopy
function for now, and we can always add a reflink-only function later — I’m pointing this out in case others think differently.
Add a function to copy via reflink if possible or fall back to the normal io.Copy(). c/image uses this function internally[1] however I like to export this and use it in podman and I think this package here in c/storage is the most logical location for it. Note compared to the c/image version I am calling unix.IoctlFileClone() directly instead of the raw syscall function. [1] https://github.com/containers/image/tree/main/internal/reflink Signed-off-by: Paul Holzinger <pholzing@redhat.com>
On modern Linux BTW Rust automatically uses that by default via specialization for its std::io::copy |
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.
/lgtm
Thanks!
Add a function to copy via reflink if possible or fall back to the normal io.Copy().
c/image uses this function internally[1] however I like to export this and use it in podman and I think this package here in c/storage is the most logical location for it. Note compared to the c/image version I am calling unix.IoctlFileClone() directly instead of the raw syscall function.
[1] https://github.com/containers/image/tree/main/internal/reflink