[PATCH] libstdc++: use copy_file_range, improve sendfile in filesystem::copy_file
Jannik Glückert
jannik.glueckert@gmail.com
Mon Mar 6 23:45:16 GMT 2023
The current copy_file implementation is suboptimal. It only uses
sendfile for files smaller than 2GB, falling back to a userspace copy,
and does not support copy_file_range at all.
copy_file_range is particularly of increasing importance with the
adoption of reflinks in filesystems.
I am pretty sure I got some of the formatting wrong, feel free to tear apart.
I don't know if sendfile has identical semantics on linux as it does
on solaris, if someone could test with a big file that'd be great.
Otherwise, this should not regress. The implementation will fall back
to sendfile / userspace copy if copy_file_range is not available for
the target paths.
The copy implementations for sendfile and copy_file_range were put
into separate functions and the callee code simplified to the point
where you can basically just copy-paste it to add a new
implementation, should new interesting syscalls pop up.
Best
Jannik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libstdc-also-use-sendfile-for-big-files.patch
Type: text/x-patch
Size: 3945 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20230307/baa3da14/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-libstdc-use-copy_file_range.patch
Type: text/x-patch
Size: 4200 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20230307/baa3da14/attachment-0001.bin>
More information about the Libstdc++
mailing list