Systemd/src/nspawn
Luke Shumaker 677a72cd3e nspawn: mount_sysfs(): Unconditionally mkdir /sys/fs/cgroup
Currently, mount_sysfs() only creates /sys/fs/cgroup if cg_ns_supported().
The comment explains that we need to "Create mountpoint for
cgroups. Otherwise we are not allowed since we remount /sys read-only.";
that is: that we need to do it now, rather than later.  However, the
comment doesn't do anything to explain why we only need to do this if
cg_ns_supported(); shouldn't we _always_ need to do it?

The answer is that if !use_cgns, then this was already done by the outer
child, so mount_sysfs() only needs to do it if use_cgns.  Now,
mount_sysfs() doesn't know whether use_cgns, but !cg_ns_supported() implies
!use_cgns, so we can optimize" the case where we _know_ !use_cgns, and deal
with a no-op mkdir_p() in the false-positive where cgns_supported() but
!use_cgns.

But is it really much of an optimization?  We're potentially spending an
access(2) (cg_ns_supported() could be cached from a previous call) to
potentially save an lstat(2) and mkdir(2); and all of them are on virtual
fileystems, so they should all be pretty cheap.

So, simplify and drop the conditional.  It's a dubious optimization that
requires more text to explain than it's worth.
2018-07-20 12:12:03 -04:00
..
meson.build Drop my copyright headers 2018-06-14 13:03:20 +02:00
nspawn-cgroup.c nspawn: sync_cgroup(): Rename arg_uid_shift -> uid_shift 2018-07-20 12:12:02 -04:00
nspawn-cgroup.h nspawn: Move cgroup mount stuff from nspawn-mount.c to nspawn-cgroup.c 2018-07-20 12:12:02 -04:00
nspawn-def.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-expose-ports.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-expose-ports.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-gperf.gperf nspawn: similar to the previous patches, also make /etc/localtime handling more configurable 2018-05-22 16:21:26 +02:00
nspawn-mount.c nspawn: mount_sysfs(): Unconditionally mkdir /sys/fs/cgroup 2018-07-20 12:12:03 -04:00
nspawn-mount.h nspawn: Move cgroup mount stuff from nspawn-mount.c to nspawn-cgroup.c 2018-07-20 12:12:02 -04:00
nspawn-network.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-network.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-patch-uid.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-patch-uid.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-register.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-register.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-seccomp.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-seccomp.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-settings.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-settings.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-setuid.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-setuid.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-stub-pid1.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn-stub-pid1.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
nspawn.c nspawn: Simplify tmpfs_patch_options() usage, and trickle that up 2018-07-20 12:12:02 -04:00
test-nspawn-tables.c test-nspawn-tables: add another "tables" test 2018-05-28 10:40:00 +02:00
test-patch-uid.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00