imagecache: fall back to legacy mount on pre-6.5 kernels - #504
Open
Mesut Oezdil (mesutoezdil) wants to merge 8 commits into
Open
imagecache: fall back to legacy mount on pre-6.5 kernels#504Mesut Oezdil (mesutoezdil) wants to merge 8 commits into
Mesut Oezdil (mesutoezdil) wants to merge 8 commits into
Conversation
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.
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.
Benjamin Elder (BenTheElder)
left a comment
Collaborator
There was a problem hiding this comment.
description is out of date.
agentic review pass (human reviewed before submission) comments inline
mountOverlay was reading any error from the first lowerdir+ fsconfig call as a pre-6.5 kernel and falling back to legacy mount(2). A bad lowerdir path fails that same call (ENOENT) on 6.5+, so it was being misreported as a kernel version problem instead of the real error. Now the fallback only triggers when the kernel's fs context log says the parameter is unrecognized; any other error is returned as-is. Also guard mountOverlay against an empty lowers slice, unreachable today but no longer implicitly safe once lowers[0] is read this early.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: mountOverlay tries lowerdir+ directly on the first layer. If
the kernel does not recognize it, that call fails immediately and
queues "Unknown parameter" on the fs context log; only that specific
diagnostic triggers the fallback to a plain mount(2) call built from
the same lowerdir list, so a bad lowerdir path (ENOENT) is reported
as-is instead of being misread as a kernel version problem. 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 test that
forces the fallback with an unrecognized option name and one for
the option string builder.