Skip to content

libct: Enforce nr_inodes=2 to fix Focal mount errors#5353

Open
lifubang wants to merge 2 commits into
opencontainers:mainfrom
lifubang:fix-maskdir-nrinode-2
Open

libct: Enforce nr_inodes=2 to fix Focal mount errors#5353
lifubang wants to merge 2 commits into
opencontainers:mainfrom
lifubang:fix-maskdir-nrinode-2

Conversation

@lifubang

@lifubang lifubang commented Jun 29, 2026

Copy link
Copy Markdown
Member

On most kernels nr_inodes=1 works fine. However, Ubuntu 20.04 (Focal) with
the official 5.4 kernel carries a private patch in mm/shmem.c that rejects
"nr_inodes<2", so let's keep nr_inodes=2 here!

This PR also add a fall back to legacy runc behavior for uncertain kernel compatibility.

Fix: #5348

@rata rata left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. @lifubang thanks for the quick fix!

I think setting the limit a little higher on the first try is slightly better, but I'm fine doing this for a quick release also. If you change it, there is no need to request a review again :)

Comment thread libcontainer/rootfs_linux.go Outdated
// maskDir mounts a read-only tmpfs on top of the specified path.
func maskDir(path, mountLabel string) error {
return mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1,nr_inodes=1", mountLabel))
err := mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1,nr_inodes=1", mountLabel))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not switch this to 2 also?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed now.

@rata rata added the backport/1.5-todo A PR in main branch which needs to be backported to release-1.5 label Jun 29, 2026
@lifubang lifubang force-pushed the fix-maskdir-nrinode-2 branch from 2d65451 to 822bb3f Compare June 29, 2026 15:56
@lifubang lifubang changed the title libct: fallback when kernel rejects nr_inodes=1 libct: enforce nr_inodes=2 to prevent mount errors on Focal kernels Jun 29, 2026
@lifubang lifubang changed the title libct: enforce nr_inodes=2 to prevent mount errors on Focal kernels libct: Enforce nr_inodes=2 to fix Focal mount errors Jun 29, 2026
@lifubang lifubang force-pushed the fix-maskdir-nrinode-2 branch 2 times, most recently from cbc961f to 6b26f20 Compare June 29, 2026 16:04
lifubang added 2 commits June 30, 2026 00:06
On most kernels `nr_inodes=1` works fine. However, Ubuntu 20.04 (Focal) with
the official 5.4 kernel carries a private patch in mm/shmem.c that rejects
"nr_inodes<2", so let's keep `nr_inodes=2` here!

Signed-off-by: lifubang <lifubang@acmcoder.com>
We don't know whether some kernels will fail with "nr_blocks=1,nr_inodes=2",
so let's fall back to the old runc behavior of mounting a tmpfs without
these options.

Signed-off-by: lifubang <lifubang@acmcoder.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.4-todo A PR in main branch which needs to backported to release-1.4 backport/1.5-todo A PR in main branch which needs to be backported to release-1.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recent update to moby-runc causes execution failures on Ubuntu:Focal

2 participants