Repository navigation
fix(boxes): a box's disk figure counts only what is on the box directory's own device - #3390
Conversation
BoxDir::disk_bytes walked into a mount under the box's tree and counted what another device holds, which a reap does not free. The walk now stays on the box directory's own device and skips the mount point. A new test bind-mounts a tmpfs under a box's tree inside a mount namespace, and skips with the reason where unshare cannot run.
…sk-figure-counts-only-what-is-on-the-b
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: every review thread resolved at @norrietaylor resolved the last thread, which releases the approval this review had withheld. Nothing to do. |
…sk-figure-counts-only-what-is-on-the-b
A host can allow a mount namespace and still refuse a mount. The probe now mounts a tmpfs in a scratch directory, so the test skips there.
|
Round 1 of 10 on a failed check suite, pushed as
Verify Review threads the coder judged:
With a tmpfs bind-mounted under a box's tree, BoxDir::disk_bytes returns the same figure as without the mount, and box_dir_disk_stays_on_its_own_device checks it. Notes from the agent: This round changes only the test's skip probe. The probe now runs |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to architecture.md line 502. The disk figure for a box now counts only what a reap frees on the box directory's own device. The new commit changes only the skip probe of the test. The probe now mounts a tmpfs, as the test body does. The production code is the same as at the head that got the prior PASS.
Ruled at 20ae468 against gominimal/arch@15b603e6afb8 by claude-opus-5-5.
There was a problem hiding this comment.
APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/boxes/src/store.rs:2511.
minimal-review — advisory review
Verdict COMMENT — No findings.
Panel: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.
There was a problem hiding this comment.
Reviewed against D3090 at 20ae4680. allocated_bytes_under walks with .same_file_system(true) and skips any entry whose device is not the root's, so a mount under the box and its mount point count nothing. The doc comment states the same-device bind-mount limit. box_dir_disk_stays_on_its_own_device runs in its own mount namespace, binds a tmpfs under the box tree, and checks the figure drops by exactly the mount point's blocks and comes back after umount. It skips with the reason where the host cannot mount a tmpfs in a namespace. The LOW probe thread is fixed by 20ae4680 (the probe now mounts a tmpfs).
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @norrietaylor closed the last one. The review of 20ae468072d4 withheld this approval on the threads open then. Posted as a comment, as the review itself was; the check and the label carry it.
Defect
Fixes #3379
crates/boxes/src/store.rsTask marker
Proof
With a tmpfs bind-mounted under a box's tree, BoxDir::disk_bytes does not count the 4 MiB file on the mount. The new test box_dir_disk_stays_on_its_own_device shows this. Without the fix, the same test fails with 4263936 against 69632.
Notes from the agent: Besides .same_file_system(true), allocated_bytes_under also skips any entry whose device is not the root's device. walkdir does not descend into the mount point, but it still yields it, with the mounted root's metadata. The mount point counts nothing, because the directory under it is hidden. So the figure with the mount is the figure without it, less the blocks of the empty mount-point directory. The test asserts this exact relation. On a tmpfs that directory holds 0 blocks, so the two figures are equal there. Limitation: a bind mount from the box directory's own filesystem has the same st_dev, so neither check sees it, and its files still count. The doc comment says so. A full fix needs a mount id (statx STATX_MNT_ID) or /proc/self/mountinfo. The test runs its own test binary again under
unshare --user --map-root-user --mount, and prints a skip reason when unshare cannot run. I checked that the test fails with the fix disabled, and then restored the fix. cargo clippy -p boxes --all-targets is clean.Tests
cargo test -p boxes box_dir_disk_stays_on_its_own_devicecargo test -p boxes box_dir_disk_counts_what_a_reap_freesVerify
min task run agent-verifypassed ([tasks.verify]).Base
The base branch moved while the coder worked; it was merged in before the tests ran.