From 59f9de8d81c717da10fb3a6d249562fe977774f6 Mon Sep 17 00:00:00 2001 From: wanglu210 Date: Wed, 3 Aug 2022 15:20:54 +0800 Subject: [PATCH] ignore devices marked as hidden in sysfs and fix reading hidden sysfs attribure (cherry picked from commit 7b6c97c380f6750e709353cace616c0c5bed099b) --- ...t-Fix-reading-hidden-sysfs-attribute.patch | 30 ++++++++++++ ...es-marked-as-hidden-in-sysfs-1856974.patch | 47 +++++++++++++++++++ python-blivet.spec | 11 ++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-reading-hidden-sysfs-attribute.patch create mode 100644 backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch diff --git a/backport-Fix-reading-hidden-sysfs-attribute.patch b/backport-Fix-reading-hidden-sysfs-attribute.patch new file mode 100644 index 0000000..9ce9a08 --- /dev/null +++ b/backport-Fix-reading-hidden-sysfs-attribute.patch @@ -0,0 +1,30 @@ +From ceeb75df8362f848cd2c11caaba04c5efdc4629d Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 30 Jul 2020 12:36:35 +0200 +Subject: [PATCH] Fix reading hidden sysfs attribute + +util.get_sysfs_attr returns a string so bool(hidden) is always +True and we hide all devices. + +Reference:https://github.com/storaged-project/blivet/commit/191a6961f13bd868052346047d0c1dc24b19f09e +Conflict:NA +--- + blivet/udev.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/blivet/udev.py b/blivet/udev.py +index 8b3fc58..5788a5e 100644 +--- a/blivet/udev.py ++++ b/blivet/udev.py +@@ -1004,4 +1004,7 @@ def device_is_nvdimm_namespace(info): + def device_is_hidden(info): + sysfs_path = device_get_sysfs_path(info) + hidden = util.get_sysfs_attr(sysfs_path, "hidden") +- return bool(hidden) ++ if not hidden or not hidden.isnumeric(): ++ return False ++ ++ return bool(int(hidden)) +-- +2.27.0 + diff --git a/backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch b/backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch new file mode 100644 index 0000000..f5bed65 --- /dev/null +++ b/backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch @@ -0,0 +1,47 @@ +From 7297046bdeb98449f4b224d13548ea97aa411aad Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 21 Jul 2020 13:26:40 +0200 +Subject: [PATCH] Ignore devices marked as hidden in sysfs(#1856974) + +NVMe multipath devices have a special internal hidden devices that +are visible in /sys/block but not directly usable so we should +ignore these as well as all devices with the hidden attribute. + +Reference:https://github.com/storaged-project/blivet/commit/8957eb1f82a37542ea1ae3990b6068b3cf90a3be +Conflict:NA +--- + blivet/populator/populator.py | 3 +++ + blivet/udev.py | 6 ++++++ + 2 files changed, 9 insertions(+) + +diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py +index 465c272..1d6daa6 100644 +--- a/blivet/populator/populator.py ++++ b/blivet/populator/populator.py +@@ -247,6 +247,9 @@ class PopulatorMixin(object): + return + + log.info("scanning %s (%s)...", name, sysfs_path) ++ if udev.device_is_hidden(info): ++ log.info("device %s is marked as hidden in sysfs, ignoring") ++ return + + # make sure we note the name of every device we see + self._add_name(name) +diff --git a/blivet/udev.py b/blivet/udev.py +index c85eb3d..8b3fc58 100644 +--- a/blivet/udev.py ++++ b/blivet/udev.py +@@ -999,3 +999,9 @@ def device_is_nvdimm_namespace(info): + devname = info.get("DEVNAME", "") + ninfo = blockdev.nvdimm_namespace_get_devname(devname) + return ninfo is not None ++ ++ ++def device_is_hidden(info): ++ sysfs_path = device_get_sysfs_path(info) ++ hidden = util.get_sysfs_attr(sysfs_path, "hidden") ++ return bool(hidden) +-- +2.27.0 + diff --git a/python-blivet.spec b/python-blivet.spec index 43fd08b..e0f6786 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -3,7 +3,7 @@ Name: python-blivet Version: 3.2.2 -Release: 8 +Release: 9 Epoch: 1 Summary: A python module for system storage configuration License: LGPLv2+ @@ -28,6 +28,9 @@ Patch9001: huawei-fix-allocate-partitions-threw-exception-when-raid.patch Patch6003: backport-Convert-LVM-filter-lists-to-sets.patch Patch6004: backport-Remove-action-device-from-LVM-reject-list.patch +Patch6005: backport-Ignore-devices-marked-as-hidden-in-sysfs-1856974.patch +Patch6006: backport-Fix-reading-hidden-sysfs-attribute.patch + %description The python-blivet package is a python module for examining and modifying storage configuration. @@ -127,6 +130,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install %doc README %changelog +* Thu Aug 4 2022 wanglu - 1:3.2.2-9 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:ignore devices marked as hidden in sysfs and fix reading hidden sysfs attribute + * Fri Dec 10 2021 yanan - 3.2.2-8 - Type:bugfix - ID:NA -- Gitee