summaryrefslogtreecommitdiffstats
path: root/src/core/device.c
diff options
context:
space:
mode:
authorMichal Sekletar <msekletar@users.noreply.github.com>2017-06-23 02:29:15 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-06-23 02:29:15 +0200
commit05e33aa1d5c074df863d9de4bf236dd676347a4c (patch)
tree1baf8075f1399dd61c6cc612e8b4f25225941cf1 /src/core/device.c
parentcore: dbus: Interpret released names properly (#6175) (diff)
downloadsystemd-05e33aa1d5c074df863d9de4bf236dd676347a4c.tar.xz
systemd-05e33aa1d5c074df863d9de4bf236dd676347a4c.zip
core: unset sysfs path after transition to dead state (#6174)
Device is gone and most likely it will get garbage collected. However in cases when it doesn't get gc'ed (because it is referenced by some other unit, e.g. mount from fstab) we need to unset sysfs. This is because when device appears next time, possibly, with different sysfs path we need to update the sysfs path. Current code could end up caching stale sysfs path forever. In reality this is not a problem for normal disks (unless you swap them during system runtime). However this issue causes failures to mount filesystems on LVM where sysfs path depends on activation order (i.e. logical volumes from volume group that is activated first get assigned lower dm-X numbers and corresponding syspaths). Fixes #6126.
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/device.c b/src/core/device.c
index da008f6041..77601c5520 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -501,12 +501,16 @@ static void device_update_found_one(Device *d, bool add, DeviceFound found, bool
* now referenced by the kernel, then we assume the
* kernel knows it now, and udev might soon too. */
device_set_state(d, DEVICE_TENTATIVE);
- else
+ else {
/* If nobody sees the device, or if the device was
* previously seen by udev and now is only referenced
* from the kernel, then we consider the device is
* gone, the kernel just hasn't noticed it yet. */
+
device_set_state(d, DEVICE_DEAD);
+ device_unset_sysfs(d);
+ }
+
}
static int device_update_found_by_sysfs(Manager *m, const char *sysfs, bool add, DeviceFound found, bool now) {