[systemd-devel] [PATCH v2] dev-root.device is not active, results in an umount spree
Martin Pitt
martin.pitt at ubuntu.com
Sun May 17 06:54:03 PDT 2015
Hello again,
Martin Pitt [2015-05-17 13:02 +0200]:
> - Alternative: Fix device_found_node() to create a .device with the
> correct ("tentative") state if the device doesn't exist in /dev/
> or udev (yet). Then manager_load_unit() would not create a "dead"
> stub .device any more, but use the existing "tentative" .device
> and mounts would also stop being auto-unmounted.
The attached patches implement this now. The whole device state logic
with the "tentative" handling isn't that easy to understand, and
indeed there are still some "nice" traps.
The first patch fixes the incomplete handling of tentative devices
that got picked up by mountinfo -- you NACK'ed the first patch which
would avoid creating the stub "dead" .device units for those, so this
now makes sure that this comment in device_found_node():
/* This is called whenever we find a device referenced in
* /proc/swaps or /proc/self/mounts. Such a device might be
* mounted/enabled at a time where udev has not finished
* probing it yet, and we thus haven't learned about it
* yet. In this case we will set the device unit to
* "tentative" state. */
will actually become true: i. e. with this patch this now creates a
.device unit with found == DEVICE_FOUND_MOUNT and thus state ==
DEVICE_TENTATIVE. This avoids the aforementioned trap of
manager_load_unit() creating bogus units later on, but keeps the idea
of having a real .device unit in "tentative" state for non-udev
devices.
This fixes the original "systemd immediately unmounts my mounts" bug,
but not for very long: If you remount or unmount just one mount on a
tentative device, mountinfo changes, and device_found_node() now calls
device_update_found_one() with "add == 0". Then
n = add ? (d->found | found) : (d->found & ~found);
would unset the previous DEVICE_FOUND_MOUNT flag, leaving 0 (i. e.
DEVICE_NOT_FOUND). Thus the previously "tentative" device would once
again be set to "dead", and systemd would unmount all other mounts
from it. This must never happen, we simply can't declare tentative
devices as dead and clean up their unmounts, this only works for
"plugged" ones that we know via udev.
I tested this now with various container setups (with and without
udev/writable /sys), real iron, VM, and the infamous "remove mounted
CD"; the latter still cleans up the stale mount point as intended.
Perhaps it's time to stick our heads together again, write down the
use cases where this stuff should actually do something (e. g. cleanup
mounts and track .device units), and see if we can simplify this
again?
Thanks,
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-device-create-units-with-intended-found-value.patch
Type: text/x-diff
Size: 4968 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150517/608f98ef/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-device-Don-t-bind-to-nonexisting-devices.patch
Type: text/x-diff
Size: 2469 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150517/608f98ef/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150517/608f98ef/attachment-0001.sig>
More information about the systemd-devel
mailing list