mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #5359 from lifubang/backport-5358-to-release-1.5
[release-1.5 backport] libct: retry with nr_inodes=2 to fix Focal mount errors
This commit is contained in:
@@ -1323,16 +1323,14 @@ func verifyDevNull(f *os.File) error {
|
|||||||
|
|
||||||
// maskDir mounts a read-only tmpfs on top of the specified path.
|
// maskDir mounts a read-only tmpfs on top of the specified path.
|
||||||
func maskDir(path, mountLabel string) error {
|
func maskDir(path, mountLabel string) error {
|
||||||
// On most kernels `nr_inodes=1` works fine. However, Ubuntu 20.04 (Focal) with
|
err := mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1,nr_inodes=1", mountLabel))
|
||||||
// the official 5.4 kernel carries a private patch in mm/shmem.c that rejects
|
if err != nil {
|
||||||
// "nr_inodes<2", so let's keep `nr_inodes=2` here!
|
// On most kernels `nr_inodes=1` works fine. However, Ubuntu 20.04 (Focal) with
|
||||||
// For reference, search for "case Opt_nr_inodes" in:
|
// the official 5.4 kernel carries a private patch in "mm/shmem.c" that rejects
|
||||||
// https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/mm/shmem.c?h=Ubuntu-5.4.0-216.236
|
// `nr_inodes<2`, so retry with `nr_inodes=2` here.
|
||||||
err := mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1,nr_inodes=2", mountLabel))
|
// For reference, search for "case Opt_nr_inodes" in:
|
||||||
// We don't know whether some kernels will fail with "nr_inodes=2",
|
// https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/mm/shmem.c?h=Ubuntu-5.4.0-216.236
|
||||||
// so let's fall back to mount a tmpfs without this option.
|
err = mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1,nr_inodes=2", mountLabel))
|
||||||
if errors.Is(err, unix.EINVAL) {
|
|
||||||
err = mount("tmpfs", path, "tmpfs", unix.MS_RDONLY, label.FormatMountLabel("nr_blocks=1", mountLabel))
|
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user