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

copy_file_range op? #831

Open
SUPERCILEX opened this issue Mar 22, 2023 · 6 comments
Open

copy_file_range op? #831

SUPERCILEX opened this issue Mar 22, 2023 · 6 comments

Comments

@SUPERCILEX
Copy link

SUPERCILEX commented Mar 22, 2023

There's splice but no copy_file_range. It'd be great to have.

@axboe
Copy link
Owner

axboe commented Mar 23, 2023

copy_file_range() just uses splice underneath the covers for the generic implementation anyway, can't you just use that directly from io_uring as well?

If not, it could certainly be wired up. But the majority of the work would be enabling nonblocking issue of it, otherwise you'd end up in the same situation potentially as your unlink issue.

@SUPERCILEX
Copy link
Author

Splice only works if one of the FDs is a pipe according the docs, so that won't work.

@axboe
Copy link
Owner

axboe commented Mar 23, 2023

Right, so you'd splice to a pipe, splice from a pipe. Not ideal, but it'd work.

@SUPERCILEX
Copy link
Author

Won't that introduce an unnecessary copy?

@vlovich
Copy link

vlovich commented Oct 14, 2023

Yeah, I think a real copy_file_range implementation is required. Many filesystems these days support reflinks which copy_file_range would take advantage of while splice would generate a copy.

       copy_file_range() gives filesystems an opportunity to implement
       "copy acceleration" techniques, such as the use of reflinks
       (i.e., two or more inodes that share pointers to the same copy-
       on-write disk blocks) or server-side-copy (in the case of NFS).

So if I'm copying on the same XFS/BTFS/EXT4 filesystem (& recently ZFS too I believe), copy_file_range would copy a few inodes max regardless of the file size (+not actually consume that space) whereas splice would duplicate the entire file.

copy_file_range is only a splice under the hood when copying across filesystems. Within a single filesystem there's an accelerated path available.

@saltzm
Copy link

saltzm commented Oct 15, 2024

FWIW I was also just wishing this existed so that I could make use of reflinks. I think it could also be done using ioctl_ficlonerange) but AFAICT there's no way to do that with iouring right now either. It's also less portable than copy_file_range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants