Skip to content

fix(vmm): use the real FICLONE ioctl number - #322

Merged
WaylandYang merged 4 commits into
devfrom
fix/ficlone-ioctl-number
Sep 14, 2026
Merged

WaylandYang merged 4 commits into
devfrom
fix/ficlone-ioctl-number

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

chain::reflink_copy passed 0x40209409 as FICLONE. The real number is _IOW(0x94, 9, int) = 0x40049409. The kernel matches the full ioctl number, including the size field, so it answered ENOTTY. The fallback treats ENOTTY as "this filesystem has no reflink", so every call silently fell back to a full streamed copy: chain-assembly base memory, and the bake's rootfs baseline clone. That happened even on btrfs, XFS, and ZFS 2.2+.

Found by @jrimmer while measuring #321 (described in a comment there, but the change wasn't in that branch), so it lands on its own here.

Verification

On Ubuntu 22.04 / kernel 5.15, using an XFS loopback made with reflink=1 and a 200 MiB random source file:

0x40209409 -> ENOTTY
0x40049409 -> clone OK
df used: 240 MiB for src + clone (extents shared); cmp: content identical

A unit test pins the constant to its _IOW derivation.

🤖 Generated with Claude Code

WaylandYang and others added 3 commits September 14, 2026 12:54
0x40209409 encodes a 32-byte payload; FICLONE is _IOW(0x94, 9, int) =
0x40049409. The kernel answered ENOTTY, which the fallback reads as no
reflink, so every reflink_copy streamed a full copy on every
filesystem. Reported by @jrimmer in #321.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@WaylandYang
WaylandYang merged commit bbf23a9 into dev Sep 14, 2026
6 checks passed
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

Successfully merging this pull request may close these issues.

1 participant