summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun'ichi Nomura <j-nomura@ce.jp.nec.com>2019-12-03 16:52:02 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-02-05 17:27:48 +0100
commitc672dcd2124c44803d5e2867f76931635a993426 (patch)
tree653b3cfcc38d28ee12c36f22f476b8f2e3644bd6
parenta592a40564df3a29d43a04387ea419706091bf12 (diff)
downloadsystemd-c672dcd2124c44803d5e2867f76931635a993426.tar.gz
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 (cherry picked from commit 1d086a6e59729635396204fc05234f1d3caa0847) (cherry picked from commit e6d694254fe115cc04852732172959998e051b87)
-rw-r--r--src/core/mount.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index 959b8fbed2..ba1e1af10c 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1530,7 +1530,7 @@ static int mount_setup_existing_unit(
if (r > 0)
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;
MOUNT(u)->from_proc_self_mountinfo = true;