Skip to content

perf: remember a filesystem without reflink and say so once - #206

Merged
CMGS merged 2 commits into
masterfrom
perf/reflink-capability-cache
Sep 2, 2026
Merged

perf: remember a filesystem without reflink and say so once#206
CMGS merged 2 commits into
masterfrom
perf/reflink-capability-cache

Conversation

@CMGS

@CMGS CMGS commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

ReflinkCopy tried FICLONE on every disk copy and fell back to SparseCopy silently, so on an ext4 root every clone paid a create, ioctl and unlink for nothing and the operator never learned that clones copy their disks in full (audit item cocoon-host D1).

  • The destination directory's filesystem id is cached the first time FICLONE answers EOPNOTSUPP or ENOTTY; later copies on that filesystem skip the attempt. Only those two errnos mark a filesystem: a cross-device or per-file failure still falls back without poisoning the cache.
  • One warning per filesystem names the directory and the errno.
  • ReflinkCopy takes the caller's context for that log; both in-repo callers already had one.
  • Linux test: after one copy in a temp dir, the cache agrees with a fresh FICLONE on the same directory (holds on ext4, tmpfs, btrfs and xfs alike). Run on the .79 Linux host (ext4): PASS.

Consumers: cocoon-macos calls utils.ReflinkCopy at two sites (cmd/vm/datadisk.go, cmd/vm/utils.go); they gain the context argument when cocoon-macos next bumps its cocoon pin.

Hot path: one statfs per disk copy on the clone path (a few µs) and, on a reflink-less filesystem, three syscalls fewer per copy.

CMGS added 2 commits September 2, 2026 23:22
ReflinkCopy tried FICLONE on every disk copy and fell back silently, so
an ext4 root paid a create, ioctl and unlink per clone and nobody saw
that every clone was a full copy. The destination's filesystem id is
cached the first time FICLONE answers EOPNOTSUPP or ENOTTY, later copies
go straight to SparseCopy, and one warning names the filesystem. The
copy takes the caller's context for that log.
@CMGS
CMGS merged commit 9539639 into master Sep 2, 2026
4 checks passed
@CMGS
CMGS deleted the perf/reflink-capability-cache branch September 2, 2026 16:42
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