Repository navigation
fix(copy): recover from initial zero Linux offload results - #306
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 10:39 AM ET / 14:39 UTC. ClawSweeper reviewWhat this changesConfirms initial zero-byte Linux copy-offload results before accepting EOF, and adds syscall-injection coverage to Linux CI. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main and v0.10.0 still accept an initial zero offload result as EOF. The focused repair preserves existing fallback and ownership contracts; no actionable defect was found. Priority: P2 Review scores
Verification
How this fits togetherfs-safe copies admitted source files into guarded destinations for Node.js applications. Its native Linux transfer helper serves both Root file copying and exclusive publication, selecting ordinary copying when offload is unavailable. flowchart TD
A[Admitted source file] --> B[Linux copy offload]
B --> C{Initial result is zero?}
C -->|Yes| D[Positional EOF probe]
D -->|Readable data| E[Existing ordinary copy fallback]
D -->|Confirmed EOF| F[Complete empty copy]
C -->|No| G[Continue bounded transfer]
E --> H[Existing verification and publication]
F --> H
G --> H
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain the narrow EOF confirmation and reuse the established bounded-copy fallbacks without changing public options or publication ownership. Do we have a high-confidence way to reproduce the issue? Yes: current-main source establishes false completion when the first copy_file_range call returns zero for readable data, and the contributor reports a matching injected before-fix failure. This review did not execute a reproduction. Is this the best way to solve the issue? Yes: probing the admitted descriptor distinguishes true EOF and feeds both callers into existing fallbacks without introducing another transfer implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ebc673d41bd3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
Fixes an issue where consumers using
Root.copyIn(..., { clone: "auto" })on Linux could publish an empty file whencopy_file_rangeinitially returned zero despite readable source data. The shared range-copy path could also make exclusive publication fail instead of selecting its ordinary-copy fallback.Why This Change Was Made
The native helper now confirms an initial zero result with a one-byte positional read. Confirmed EOF keeps the existing empty-file result; readable data selects the existing fallback outcome. The probe checks cancellation before and after reading, retries
EINTR, and preserves file positions and caller-owned cleanup.Rust std and Go likewise distinguish an initial zero offload result from ordinary EOF. The regression exercises our own public APIs and native binding; it introduces no production testing hook.
User Impact
Automatic Linux file copies and exclusive publication preserve readable bytes under this offload failure. Empty files, byte limits, source positions, independent destination writes, and cancellation settlement retain their existing contracts. An additional positional read occurs only when the first offload result is zero.
The historical kernel condition is modeled using syscall-result injection confined to a test-owned Node child. The host did not exhibit the fault naturally. The Linux CI job installs
straceand runs the same proof after building the package and host binding.Evidence
Before: the canonical proof passed all seven ordinary cases, then failed its first injected case:
Root.copyInreturned success with 0 of 262,181 bytes copied. A separate zero-stat-size source reproduced 0 of 167 readable bytes copied.After:
node scripts/copy-offload-eof-proof.mjspassed 14 cases on WSL2 Ubuntu, Linux 6.18.33.2, Node 26.8.2. Ordinary files, empty files, readable zero-stat-size files,maxBytes: 0, both publication paths, source offsets, and independent writes were verified with and without injection. Each injected case verifies the actual native syscall was reached and altered.The byte-limit case rejects with
too-largeand leaves no destination. The offset case preserves the caller's position at seven bytes. Ordinary copies preserve SHA-2567c3802d20e6c52781d832c75edba896a2f3744eeb52bcdd543743c106fc132ac.Scoped Rust transfer regression and three required-native Root/range-publication sibling tests passed.
cargo clippy --workspace --locked -- -D warningspassed.Full
pnpm checkpassed: 274 test files, 6,721 passing tests, and 2,157 existing platform/native skips; build, docs, and package checks passed. Initial runner-only Git metadata/pnpm lifecycle failures were resolved without changing candidate source, then the complete check passed.git diff --checkpassed. Independent P2 autoreview completed scoped-clean with no actionable P0–P2 findings.Regression coverage added for the changed behavior
Compatibility and cancellation/cleanup contracts considered
CHANGELOG.mdupdatedNo credentials, private paths, private hosts, or sensitive contents included