!70 ignore devices marked as hidden in sysfs and fix reading hidden sysfs attribute

From: @wanglu210 
Reviewed-by: @t_feng 
Signed-off-by: @t_feng
This commit is contained in:
openeuler-ci-bot 2022-08-04 02:56:48 +00:00 committed by Gitee
commit a3b1b776a5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 87 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From ceeb75df8362f848cd2c11caaba04c5efdc4629d Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
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

View File

@ -0,0 +1,47 @@
From 7297046bdeb98449f4b224d13548ea97aa411aad Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
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

View File

@ -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 <wanglu210@huawei.com> - 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 <yanan@huawei.com> - 3.2.2-8
- Type:bugfix
- ID:NA