Skip to content

core/passthrough: support the COPY_FILE_RANGE request - #262

Merged
jiangliu merged 1 commit into
cloud-hypervisor:masterfrom
jiangliu:feat/copy-file-range
Oct 10, 2026
Merged

jiangliu merged 1 commit into
cloud-hypervisor:masterfrom
jiangliu:feat/copy-file-range

Conversation

@jiangliu

Copy link
Copy Markdown
Collaborator

The ABI already defines Opcode::CopyFileRange (47) with CopyFileRangeIn, and the io_uring session already knows the request length, but the server never dispatched the opcode: a copy_file_range(2) issued on the mount was always answered with ENOSYS, so the kernel disabled the op and fell back to its generic splice-based copy loop.

Wire the request up following the LSEEK precedent: a copy_file_range() method on FileSystem and AsyncFileSystem with a default ENOSYS, the Arc delegation, a Linux-gated server handler replying WriteOut, and dispatch arms in the sync and async servers. PassthroughFs forwards it to the copy_file_range(2) syscall with the request's explicit offsets, so the backing files' own positions are neither read nor advanced and no locking against lseek() is needed; the requested length is capped at u32::MAX because the WriteOut reply reports the copied length as a u32. File systems that keep the default still get the documented ENOSYS-to-fallback contract, and VFS and OverlayFs are left on it, as they are for lseek.

Ported from PR #220 ("Add support for copy_file_range").

The ABI already defines Opcode::CopyFileRange (47) with CopyFileRangeIn,
and the io_uring session already knows the request length, but the
server never dispatched the opcode: a copy_file_range(2) issued on the
mount was always answered with ENOSYS, so the kernel disabled the op
and fell back to its generic splice-based copy loop.

Wire the request up following the LSEEK precedent: a copy_file_range()
method on FileSystem and AsyncFileSystem with a default ENOSYS, the
Arc<FS> delegation, a Linux-gated server handler replying WriteOut, and
dispatch arms in the sync and async servers.  PassthroughFs forwards it
to the copy_file_range(2) syscall with the request's explicit offsets,
so the backing files' own positions are neither read nor advanced and
no locking against lseek() is needed; the requested length is capped at
u32::MAX because the WriteOut reply reports the copied length as a u32.
File systems that keep the default still get the documented
ENOSYS-to-fallback contract, and VFS and OverlayFs are left on it, as
they are for lseek.

Ported from PR cloud-hypervisor#220 ("Add support for copy_file_range").

Co-authored-by: EJ Campbell <ejc3@users.noreply.github.com>
Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
@jiangliu jiangliu added the run-benchmark Run performance benchmark for the PR label Oct 10, 2026
@jiangliu
jiangliu merged commit 81a17a0 into cloud-hypervisor:master Oct 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-benchmark Run performance benchmark for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant