[systemd-devel] [PATCH] core/mount: only add dependencies to active units for dynamic mounts [was: Re: unit: When stopping due to BindsTo=, log which unit caused it]

Martin Pitt martin.pitt at ubuntu.com
Thu Feb 26 12:40:33 PST 2015


Hey Colin,

Colin Walters [2015-02-26 13:05 -0500]:
> The patch description seems wrong to me; "systemctl status /dev/vda1" clearly
> shows the device units are active while i'm in the initramfs.

Ah, then I misunderstood the problem, and the patch will most probably
not work. I tested that with the Debian-ish initramfs without systemd
(or any other init system, /sbin/init is just a shell script).

> I haven't tried your patch, but I do suspect it will work.  But why touch
> the other bits of code?  Why not just do:
> 
> if (!is_fragment)
>     return 0;
> 
> ?
> 
> in mount.c?
> 
> I'd title the resulting patch something like "Only add device dependencies for fragment mounts" or
> "Don't add device dependencies for dynamic mounts".

That would get us back to the situation before the original commit
06e97888, where mounts of hotplugged devices/removable media which got
removed/ejected aren't cleaned up automatically. These are
non-fragment mounts which we *do* want to bind on the .device.

The original thread started here:

  http://lists.freedesktop.org/archives/systemd-devel/2015-January/026948.html

(but was dispersed a bit)

I'm not sure why in your case the fs gets unmounted.  If you mount it
while systemd is already running, the corresponding .device should
either already exist and be active (and you confirmed that above), or
never exist because it's a virtual device/bind mount/one of the cases
which are checked before calling unit_add_node_link(). Why does the
.device suddenly go away for you then?

Most probably your initramfs has systemd, but it gets stopped and the
"real" root file system gets another systemd instance after pivoting.
The mount is still in /proc/mounts, but due to the restarting systemd
all of its units go away. Is that the case?

I don't have a spontaneous idea how to fix that in a clean way (but
I'm not nearly familiar enough with the systemd code and unit
handling). Ideas anyone?

An alternative would be to revert 06e97888 and fix stale CD mounts in
another way, like picking any of the options in the above thread. E.
g. udev could run in the normal root mount namespace again, and the
stale mounts get cleaned up via udev rules. But as far as I understood
Lennart he didn't like that either.

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


More information about the systemd-devel mailing list