daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ecbff1
From d5ab3fdc9bf9353478e7c0987b3830f14bbdefae Mon Sep 17 00:00:00 2001
ecbff1
From: Michal Sekletar <msekleta@redhat.com>
ecbff1
Date: Thu, 22 Jun 2017 14:26:39 +0200
ecbff1
Subject: [PATCH] core: unset sysfs path after transition to dead state
ecbff1
ecbff1
Device is gone and most likely it will get garbage collected. However in
ecbff1
cases when it doesn't get gc'ed (because it is referenced by some
ecbff1
other unit, e.g. mount from fstab) we need to unset sysfs. This is
ecbff1
because when device appears next time, possibly, with different sysfs
ecbff1
path we need to update the sysfs path. Current code could end up caching
ecbff1
stale sysfs path forever.
ecbff1
ecbff1
In reality this is not a problem for normal disks (unless you swap them
ecbff1
during system runtime). However this issue causes failures to mount
ecbff1
filesystems on LVM where sysfs path depends on activation
ecbff1
order (i.e. logical volumes from volume group that is activated first
ecbff1
get assigned lower dm-X numbers and corresponding syspaths).
ecbff1
ecbff1
Fixes #6126
ecbff1
ecbff1
(cherry picked from commit 0e139cac0318de09e6f4c1a4fc61388f7e541ebd)
ecbff1
ecbff1
Resolves: #1408916
ecbff1
---
ecbff1
 src/core/device.c | 6 +++++-
ecbff1
 1 file changed, 5 insertions(+), 1 deletion(-)
ecbff1
ecbff1
diff --git a/src/core/device.c b/src/core/device.c
ecbff1
index befbae83f..63a04bdd3 100644
ecbff1
--- a/src/core/device.c
ecbff1
+++ b/src/core/device.c
ecbff1
@@ -474,12 +474,16 @@ static void device_update_found_one(Device *d, bool add, DeviceFound found, bool
ecbff1
                  * now referenced by the kernel, then we assume the
ecbff1
                  * kernel knows it now, and udev might soon too. */
ecbff1
                 device_set_state(d, DEVICE_TENTATIVE);
ecbff1
-        else
ecbff1
+        else {
ecbff1
                 /* If nobody sees the device, or if the device was
ecbff1
                  * previously seen by udev and now is only referenced
ecbff1
                  * from the kernel, then we consider the device is
ecbff1
                  * gone, the kernel just hasn't noticed it yet. */
ecbff1
+
ecbff1
                 device_set_state(d, DEVICE_DEAD);
ecbff1
+                device_unset_sysfs(d);
ecbff1
+        }
ecbff1
+
ecbff1
 }
ecbff1
 
ecbff1
 static int device_update_found_by_sysfs(Manager *m, const char *sysfs, bool add, DeviceFound found, bool now) {