Repository navigation
Conversation
Somehow I miss this part of patch. |
Yeah, sorry - it isn't there any more. Someone pointed that that approach couldn't work because I was misunderstanding the independence of transaction. So I came up with a new approach. |
I agree github makes it hard to follow. I answered in the initial issue and I think this approach is the simplest one, we might want to document the new behavior though. |
|
@poettering could you have a look at Neil's changes ? I think they make sense and remove the need of the asymmetric deps. |
|
Hmm, this doesn't look right, sorry. The thing is that deps never go away after they are created. That means if you have a mount unit that is started once, then stopped it will have gained the dep, and that dep won't go away, hence a subsequent second start will be run with it in effect... There are plans to track properly how each dep came to be, so that we can flush them out piecemeal, but that's not done yet, and not entirely trivial, but until that point I am not sure this can work... |
There was a problem hiding this comment.
I just found that the !u->default_dependencies should be inverted, i.e. the ordering dep should only be added if the mount unit has DefaultDependencies=true
Hmm I'm not sure to understand the problem here. The ordering dep patching is supposed to help during the boot process only but will have basically no effects after since at that point |
If a mount is allowed to fail (e.g. marked "nofail" in /etc/fstab) then it is likely that Before=local-fs.target would not be wanted, as that could cause an unhelpful delay (and fstab-generator excludes local-fs.target for that reason). However, once the filesystem is mounted, it is important that it doesn't get unmounted at shutdown until any services using it have completed, otherwise the unmount might fail. So at mount time, we add a Before dependency on local-fs.target. Note that, since Commit: a6d305f ("mount: add remote-fs dependencies if needed after change") we already auto-add a Before dependency on remote-fs.target for remote filesystems. This change just makes local mounts behave in the same way. Fixes systemd#5991
When a mount unit is mounted, one of Before=local-fs.target or Before=network-fs.target is added, as appropriate. This ensures they are not unmounted before services and session that are using them have completed. This needs to be documented.
|
I revised the commit to fixed the inversion of the test on ->default_dependencies. |
|
THe initial transaction should be repeatable, i.e. you should be able to "systemctl isolate emergency.target" and back to "systemctl isolate multi-user.target" and things should work. But if the the initial transaction modified tht dep tree, than it will be different from any repetition... |
|
Thanks for the pointer to repeatability of the initial transaction. I'll take your word for it that that is useful, but I have trouble seeing it as more important than the orderly normal startup and shutdown of the system - which might be seen as systemd's core responsibility. It is the orderly shutdown that isn't working correctly here. Until the removal of individual dependencies is implemented, you might need to just trigger a "daemon-reload" once emergency.target is reached. |
|
Until this is fixed, mounting and unmounting of remote filesystems, particularly at shutdown, is broken. |
|
@neilbrown hey there. Didn't expect to see you here. I'm closing this since this has been unresolved for quite a few years. If this is still an issue that needs to be addressed please open a new pr. |
fstab-generator omits the Before=fs-XXX.target dependency
on automount and nofail mounts.
This causes a problem at shutdown. As the mounts are not "Before"
anything, they are initiated immediately, and might run while
services that use the mounts are still running.
This cause the mount to fail and never get unmounted.
This is particularly problematic for NFS the network can get shutdown
after these unmounts failed, and while services are still running.
If that happens, then any services (such as login sessions) using
the NFS mounts can block indefinitely - particularly if they had
written something to the NFS filesystem recently. They cannot exit
until the data is written, and that cannot happen with the network down.
So we need that "Before=" dependency, but we don't want fs-XXX.target
to have to wait for the mount to complete.
For automounts, there is no difficulty. The mount unit isn't activated
in the same transaction as the fs-XXX.target, so the ordering is not
effective. We can re-instate the Before= dependency for automounts
without causing any problems.
For nofail mounts we need a little more work. automounts set a good
example to follow. If the mount unit is activated in a separate
transaction, the Before= dependency can be restored without causing
and delays are startup. This is easily done with a timer unit.
So this patch:
a timer unit is created instead of an automount unit. This timer
unit has OnActiveSec=0 and triggers the mount unit.
Fixes #5991