teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0502-core-unset-sysfs-path-after-transition-to-dead-state.patch

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