Compare commits

...

4 Commits

Author SHA1 Message Date
Jun'ichi Nomura 1d086a6e59 mount: mark an existing "mounting" unit from /proc/self/mountinfo as "just_mounted"
When starting a mount unit, systemd invokes mount command and moves the
unit's internal state to "mounting".  Then it watches for updates of
/proc/self/mountinfo.  When the expected mount entry newly appears in
mountinfo, the unit internal state is changed to "mounting-done".
Finally, when systemd finds the mount command has finished, it checks
whether the unit internal state is "mounting-done" and changes the state
to "mounted".
If the state was not "mounting-done" in the last step though mount command
was successfully finished, the unit is marked as "failed" with following
log messages:
  Mount process finished, but there is no mount.
  Failed with result 'protocol'.

If daemon-reload is done in parallel with starting mount unit, it is
possible that things happen in following order and result in above failure.
  1. the mount unit state changes to "mounting"
  2. daemon-reload saves the unit state
  3. kernel completes the mount and /proc/self/mountinfo is updated
  4. daemon-reload restores the saved unit state, that is "mounting"
  5. systemd notices the mount command has finished but the unit state
     is still "mounting" though it should be "mounting-done"

mount_setup_existing_unit() should take into account that MOUNT_MOUNTING
is transitional state and set MOUNT_PROC_JUST_MOUNTED flag if the unit
comes from /proc/self/mountinfo so that mount_process_proc_self_mountinfo()
later can make state transition from "mounting" to "mounting-done".

Fixes: #10872
2020-01-14 12:15:09 +01:00
Lennart Poettering 9dca1d5723
Merge pull request #14561 from keszybz/docs-deellipsisize
Doc formatting fixes and link update
2020-01-14 10:08:21 +01:00
Zbigniew Jędrzejewski-Szmek 744c49e1fe docs: update link and more dots
Apparently unicode ellipsis is too much for github.
2020-01-13 21:03:15 +01:00
Zbigniew Jędrzejewski-Szmek 0a5a8f13b4 docs: say that journalctl --flush/--sync also require journald
https://github.com/systemd/systemd/pull/14549#pullrequestreview-341758182
2020-01-13 21:01:01 +01:00
4 changed files with 12 additions and 10 deletions

View File

@ -19,7 +19,7 @@ interfaces are currently used by dracut and the ArchLinux initrds.
* The initrd should mount `/run/` as a tmpfs and pass it pre-mounted when * The initrd should mount `/run/` as a tmpfs and pass it pre-mounted when
jumping into the main system when executing systemd. The mount options should jumping into the main system when executing systemd. The mount options should
be `mode=755,nodev,nosuid,strictatime` be `mode=755,nodev,nosuid,strictatime`.
* It's highly recommended that the initrd also mounts `/usr/` (if split off) as * It's highly recommended that the initrd also mounts `/usr/` (if split off) as
appropriate and passes it pre-mounted to the main system, to avoid the appropriate and passes it pre-mounted to the main system, to avoid the

View File

@ -155,6 +155,8 @@ without communicating with the `systemd` process:
Many other programs support operation without the system manager except when Many other programs support operation without the system manager except when
the specific functionality requires such communication. For example the specific functionality requires such communication. For example
`journalctl` operates almost independently, but will query the boot id when `journalctl` operates almost independently, but will query the boot id when
`--boot` option is used. `systemd-journal-remote`, `systemd-journal-upload`, `--boot` option is used; it also requires `systemd-journald` (and thus
`systemd-journal-gatewayd`, `coredumpctl`, `busctl`, `systemctl --root` also `systemd`) to be running for options like `--flush` and `--sync`.
fall into this category. `systemd-journal-remote`, `systemd-journal-upload`, `systemd-journal-gatewayd`,
`coredumpctl`, `busctl`, `systemctl --root` also fall into this category of
mostly-independent programs.

View File

@ -90,9 +90,9 @@ kernel threads are excluded too. Thus, a daemon which wants to take advantage
of this logic needs to place the following at the top of its main() function: of this logic needs to place the following at the top of its main() function:
```c ```c
...
[0][0] = '@'; [0][0] = '@';
...
``` ```
And that's already it. Note that this functionality is only to be used by And that's already it. Note that this functionality is only to be used by
@ -116,10 +116,10 @@ otherwise doesn't. Something like this:
#include <unistd.h> #include <unistd.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
...
if (access("/etc/initrd-release", F_OK) >= 0) if (access("/etc/initrd-release", F_OK) >= 0)
argv[0][0] = '@'; argv[0][0] = '@';
...
} }
``` ```
@ -190,4 +190,4 @@ few additional notes for supporting these setups:
program consult this blog story: [Socket program consult this blog story: [Socket
Activation](http://0pointer.de/blog/projects/socket-activation.html) Activation](http://0pointer.de/blog/projects/socket-activation.html)
* Consider having a look at the [initrd Interface of systemd](http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface) * Consider having a look at the [initrd Interface of systemd](https://systemd.io/INITRD_INTERFACE/).

View File

@ -1568,7 +1568,7 @@ static int mount_setup_existing_unit(
if (r > 0) if (r > 0)
flags |= MOUNT_PROC_JUST_CHANGED; flags |= MOUNT_PROC_JUST_CHANGED;
if (!MOUNT(u)->from_proc_self_mountinfo || FLAGS_SET(MOUNT(u)->proc_flags, MOUNT_PROC_JUST_MOUNTED)) if (!MOUNT(u)->from_proc_self_mountinfo || FLAGS_SET(MOUNT(u)->proc_flags, MOUNT_PROC_JUST_MOUNTED) || MOUNT(u)->state == MOUNT_MOUNTING)
flags |= MOUNT_PROC_JUST_MOUNTED; flags |= MOUNT_PROC_JUST_MOUNTED;
MOUNT(u)->from_proc_self_mountinfo = true; MOUNT(u)->from_proc_self_mountinfo = true;