Skip to content

imagecache: fall back to legacy mount on pre-6.5 kernels#504

Open
Mesut Oezdil (mesutoezdil) wants to merge 5 commits into
agent-substrate:mainfrom
mesutoezdil:fix/imagecache-legacy-mount-fallback
Open

imagecache: fall back to legacy mount on pre-6.5 kernels#504
Mesut Oezdil (mesutoezdil) wants to merge 5 commits into
agent-substrate:mainfrom
mesutoezdil:fix/imagecache-legacy-mount-fallback

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

Fixes #500.

SetupBundleRootfs mounts overlay rootfs with the new mount API,
using fsconfig lowerdir+ per layer. That option only exists on
Linux 6.5+. On older kernels every actor mount fails with a bare
EINVAL, which looks like flakiness, not a kernel version problem.

Fix: probe lowerdir+ support once (cheap fsopen/fsconfig dry run,
no real mount), log one clear line when missing, and fall back to
a plain mount(2) call built from the same lowerdir list. The legacy
path keeps the old ~34 layer cap and errors with a kernel hint if
the option string would go over the mount(2) page limit.

Tested with go test ./internal/imagecache/... on a real Linux
kernel (root, CAP_SYS_ADMIN, tmpfs upperdir), including a new test
that calls the legacy mount path directly and one for the option
string builder.

The new mount API needs overlayfs lowerdir+, which only exists on
Linux 6.5+. Probe it once at first mount and use plain mount(2) when
missing, so older kernels do not fail every actor mount with EINVAL.
Comment thread internal/imagecache/bundle_linux.go Outdated
// (Linux >= 6.5). The probe opens a throwaway fs context and tries the
// option against a directory that always exists; it never creates a
// superblock or touches the filesystem otherwise.
var lowerdirPlusSupported = sync.OnceValue(func() bool {

@BenTheElder Benjamin Elder (BenTheElder) Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally init() and friends are an anti-pattern especially interacting with the host from them ..., do we even need this probe versus just handling the error and falling back?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for feedback, i removed the separate probe. now it just tries lowerdir+ on first layer directly, if kernel doesnt know it that call fails right away, then we fall back to legacy mount. No init() and no extra state.
added a test that forces this path with a fake option name so the fallback is actually covered now.
I think it’s better this way, it’s now responding to actual behaviour (rather than an assumption). PTAL

Drop the separate startup probe. mountOverlay now tries lowerdir+
on the first layer directly; if the kernel does not recognize it,
that call fails immediately (before any path is touched), and we
fall back to legacy mount(2) from there. Simpler and the fallback
is now covered by a test that forces the failure.
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.

imagecache: probe for overlayfs lowerdir+ support and fall back to legacy mount(2) on pre-6.5 kernels

2 participants