Skip to content

fix(block): read mountinfo once for all the binds - #1205

Open
sapnasingh4852-source wants to merge 1 commit into
urunc-dev:mainfrom
sapnasingh4852-source:fix/1166-mountinfo-once
Open

sapnasingh4852-source wants to merge 1 commit into
urunc-dev:mainfrom
sapnasingh4852-source:fix/1166-mountinfo-once

Conversation

@sapnasingh4852-source

Copy link
Copy Markdown

Description

getBlockVolumes called getMountInfo for every bind mount, and every call re-read and re-parsed /proc/thread-self/mountinfo. With N binds that is N reads of the same file before anything changes.

This resolves all the binds against one snapshot of the mount table. The snapshot is refreshed right after an unmount, because unmounting a source changes the table and the following lookups have to see that change (this keeps the existing ErrMountpoint / shared-source behaviour per bind).

Related issues

How was this tested?

  • GOOS=linux go build ./pkg/unikontainers/... and GOOS=linux go vet ./pkg/unikontainers/ pass (local machine is darwin, so the package can only be built for linux here).
  • Added TestBlockVolumesShareMountInfoSnapshot, which passes 8 binds whose sources are not mounted and asserts the mount table is read exactly once. It runs on linux in CI.
  • Added BenchmarkBlockVolumesShareMountInfoSnapshot, which keeps the read/parse cost inside the measured loop so the saving is visible: 32 binds now pay for one parse instead of 32.
  • No e2e run: the block path needs real mounts / a unikernel, which I could not run locally.

LLM usage

Qoder (agent) helped with the refactor and the test; I reviewed the diff.

getBlockVolumes called getMountInfo for every bind mount, and each call
re-read and re-parsed /proc/thread-self/mountinfo. Resolve every bind
against one snapshot instead, and refresh that snapshot after an unmount
since unmounting a source changes the table the next lookup needs.

Signed-off-by: sapnasingh4852-source <sapnasingh4852@gmail.com>
@netlify

netlify Bot commented Nov 12, 2026

Copy link
Copy Markdown

👷 Deploy request for urunc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 304d421

@cmainas cmainas added invalid This doesn't seem right do-not-merge labels Nov 12, 2026
@cmainas

cmainas commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This PR does not follow the contribution guidelines: Please ensure:

  • The PR template is filled correctly.
  • Perform sufficient testing. Building and unit tests is not sufficient.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getBlockVolumes parses all of mountinfo once per bind mount

2 participants