Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shm_open doesn't work #9

Closed
beelzetron opened this issue Oct 31, 2018 · 4 comments
Closed

shm_open doesn't work #9

beelzetron opened this issue Oct 31, 2018 · 4 comments

Comments

@beelzetron
Copy link

Hi,
when I run a playbook inside the fedora-toolbox created container it returns the following error:
ERROR! Unable to use multiprocessing, this is normally caused by lack of access to /dev/shm: [Errno 30] Read-only file system

@debarshiray
Copy link
Member

I can reproduce this with:

/* gcc shm.c -lrt */

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>

int
main (void)
{
  int fd;

  fd = shm_open ("/foo", O_CREAT | O_RDWR, 0664);
  if (fd == -1)
    {
      fprintf (stderr, "shm_open failed: %s\n", strerror (errno));
      return 1;
    }

  close (fd);
  return 0;
}

However, this works:

🔹[rishi@toolbox ~]$ echo hello world >/dev/shm/bar
🔹[rishi@toolbox ~]$ ls -l /dev/shm
total 4
-rw-rw-r--. 1 rishi rishi 12 Nov  6 18:48 bar
🔹[rishi@toolbox ~]$ cat /dev/shm/bar
hello world

@debarshiray
Copy link
Member

debarshiray commented Nov 6, 2018

That tells me that open works, but shm_open doesn't, which is not suprising because /dev/shm doesn't seem to be on a tmpfs:

🔹[rishi@toolbox ~]$ df -h /dev
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            64M     0   64M   0% /dev
🔹[rishi@toolbox ~]$ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p5  415G   28G  366G   7% /dev/shm

debarshiray added a commit that referenced this issue Nov 7, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
@debarshiray debarshiray changed the title ansible multiprocessing not working inside container shm_open doesn't work Nov 7, 2018
@debarshiray
Copy link
Member

Does PR #12 fix the problem for you?

debarshiray added a commit that referenced this issue Nov 7, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
debarshiray added a commit that referenced this issue Nov 8, 2018
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] containers/podman#1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

#9
@debarshiray
Copy link
Member

I am closing this issue because the above shm_open reproducer now works for me. Feel free to reopen or leave a comment if you have reason to think otherwise.

Either way, thanks for trying fedora-toolbox and getting in touch!

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

No branches or pull requests

2 participants