|
|
803fb7 |
From 6b8fedd82c23f1d8c334c3081a1befebedc40f1f Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
803fb7 |
Date: Tue, 19 May 2015 13:50:36 +0200
|
|
|
803fb7 |
Subject: [PATCH] mount: don't claim a device is gone from /proc/self/mountinfo
|
|
|
803fb7 |
before it is gone from *all* lines
|
|
|
803fb7 |
|
|
|
803fb7 |
Devices might be referenced by multiple mount points in
|
|
|
803fb7 |
/proc/self/mountinfo, hence we should consider them unmounted only after
|
|
|
803fb7 |
they disappeared from all lines, not just from one.
|
|
|
803fb7 |
|
|
|
803fb7 |
http://lists.freedesktop.org/archives/systemd-devel/2015-May/032026.html
|
|
|
803fb7 |
(cherry picked from commit fcd8b266edf0df2b85079fcf7b099cd4028740e6)
|
|
|
803fb7 |
|
|
|
803fb7 |
Cherry-picked from:
|
|
|
803fb7 |
Resolves: #1222517
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/core/mount.c | 30 +++++++++++++++++++++++++++---
|
|
|
803fb7 |
1 file changed, 27 insertions(+), 3 deletions(-)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
803fb7 |
index fd4fb6f1b..fa63f2426 100644
|
|
|
803fb7 |
--- a/src/core/mount.c
|
|
|
803fb7 |
+++ b/src/core/mount.c
|
|
|
803fb7 |
@@ -1698,7 +1698,10 @@ fail:
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|
|
|
803fb7 |
static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
|
|
|
803fb7 |
+ _cleanup_set_free_ Set *around = NULL, *gone = NULL;
|
|
|
803fb7 |
Manager *m = userdata;
|
|
|
803fb7 |
+ const char *what;
|
|
|
803fb7 |
+ Iterator i;
|
|
|
803fb7 |
Unit *u;
|
|
|
803fb7 |
int r;
|
|
|
803fb7 |
|
|
|
803fb7 |
@@ -1765,6 +1768,8 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|
|
803fb7 |
|
|
|
803fb7 |
if (!mount->is_mounted) {
|
|
|
803fb7 |
|
|
|
803fb7 |
+ /* A mount point is gone */
|
|
|
803fb7 |
+
|
|
|
803fb7 |
mount->from_proc_self_mountinfo = false;
|
|
|
803fb7 |
|
|
|
803fb7 |
switch (mount->state) {
|
|
|
803fb7 |
@@ -1780,13 +1785,17 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|
|
803fb7 |
break;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|
|
|
803fb7 |
- if (mount->parameters_proc_self_mountinfo.what)
|
|
|
803fb7 |
- (void) device_found_node(m, mount->parameters_proc_self_mountinfo.what, false, DEVICE_FOUND_MOUNT, true);
|
|
|
803fb7 |
+ /* Remember that this device might just have disappeared */
|
|
|
803fb7 |
+ if (mount->parameters_proc_self_mountinfo.what) {
|
|
|
803fb7 |
|
|
|
803fb7 |
+ if (set_ensure_allocated(&gone, &string_hash_ops) < 0 ||
|
|
|
803fb7 |
+ set_put(gone, mount->parameters_proc_self_mountinfo.what) < 0)
|
|
|
803fb7 |
+ log_oom(); /* we don't care too much about OOM here... */
|
|
|
803fb7 |
+ }
|
|
|
803fb7 |
|
|
|
803fb7 |
} else if (mount->just_mounted || mount->just_changed) {
|
|
|
803fb7 |
|
|
|
803fb7 |
- /* New or changed mount entry */
|
|
|
803fb7 |
+ /* A mount point was added or changed */
|
|
|
803fb7 |
|
|
|
803fb7 |
switch (mount->state) {
|
|
|
803fb7 |
|
|
|
803fb7 |
@@ -1811,12 +1820,27 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|
|
803fb7 |
mount_set_state(mount, mount->state);
|
|
|
803fb7 |
break;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
+
|
|
|
803fb7 |
+ if (mount->parameters_proc_self_mountinfo.what) {
|
|
|
803fb7 |
+
|
|
|
803fb7 |
+ if (set_ensure_allocated(&around, &string_hash_ops) < 0 ||
|
|
|
803fb7 |
+ set_put(around, mount->parameters_proc_self_mountinfo.what) < 0)
|
|
|
803fb7 |
+ log_oom();
|
|
|
803fb7 |
+ }
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|
|
|
803fb7 |
/* Reset the flags for later calls */
|
|
|
803fb7 |
mount->is_mounted = mount->just_mounted = mount->just_changed = false;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|
|
|
803fb7 |
+ SET_FOREACH(what, gone, i) {
|
|
|
803fb7 |
+ if (set_contains(around, what))
|
|
|
803fb7 |
+ continue;
|
|
|
803fb7 |
+
|
|
|
803fb7 |
+ /* Let the device units know that the device is no longer mounted */
|
|
|
803fb7 |
+ (void) device_found_node(m, what, false, DEVICE_FOUND_MOUNT, true);
|
|
|
803fb7 |
+ }
|
|
|
803fb7 |
+
|
|
|
803fb7 |
return 0;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|