fix name resolution for MD devices and partitions

This commit is contained in:
bitcoffee 2020-09-15 10:26:43 +08:00
parent e7366b5efe
commit 695c9a4141
2 changed files with 56 additions and 2 deletions

View File

@ -0,0 +1,48 @@
From 4bf7ef1f6b63d025dd047fe5f1c6dea4ef6c3b40 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 12 Aug 2020 10:57:19 +0200
Subject: [PATCH] Fix name resolution for MD devices and partitions on them
UDev data for both member disks/partitions and partitions on arrays
contain the MD_* properties we must be extra careful when deciding
what name we'll use for the device.
Resolves: rhbz#1862904
---
blivet/udev.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/blivet/udev.py b/blivet/udev.py
index 66af9a98..32d6369a 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -203,9 +203,16 @@ def device_get_name(udev_info):
""" Return the best name for a device based on the udev db data. """
if "DM_NAME" in udev_info:
name = udev_info["DM_NAME"]
- elif "MD_DEVNAME" in udev_info and os.path.exists(device_get_sysfs_path(udev_info) + "/md"):
+ elif "MD_DEVNAME" in udev_info:
mdname = udev_info["MD_DEVNAME"]
- if device_is_partition(udev_info):
+ if device_is_md(udev_info):
+ # MD RAID array -> use MD_DEVNAME
+ name = mdname
+ elif device_get_format(udev_info) == "linux_raid_member":
+ # MD RAID member -> use SYS_NAME
+ name = udev_info["SYS_NAME"]
+ elif device_is_partition(udev_info):
+ # partition on RAID -> construct name from MD_DEVNAME + partition number
# for partitions on named RAID we want to use the raid name, not
# the node, e.g. "raid1" instead of "md127p1"
partnum = udev_info["ID_PART_ENTRY_NUMBER"]
@@ -214,6 +221,7 @@ def device_get_name(udev_info):
else:
name = mdname + partnum
else:
+ # something else -> default to MD_DEVNAME
name = mdname
else:
name = udev_info["SYS_NAME"]
--
2.20.1.windows.1

View File

@ -2,7 +2,7 @@
Name: python-blivet Name: python-blivet
Version: 3.2.2 Version: 3.2.2
Release: 2 Release: 3
Epoch: 1 Epoch: 1
Summary: A python module for system storage configuration Summary: A python module for system storage configuration
License: LGPLv2+ License: LGPLv2+
@ -17,7 +17,7 @@ BuildRequires: python2-devel python2-setuptools
%endif %endif
Patch0: 0001-force-lvm-plugin.patch Patch0: 0001-force-lvm-plugin.patch
Patch1: Fix-name-resolution-for-MD-devices-and-partitions-on.patch
Patch9000: fix-the-long-hostname.patch Patch9000: fix-the-long-hostname.patch
@ -120,6 +120,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install
%doc README %doc README
%changelog %changelog
* Thu Sep 15 2020 liuxin <liuxin264@huawei.com> - 3.2.2-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:bugfix raid1 dirvice cann't show when install
* Thu Jul 9 2020 zhangqiumiao <zhangqiumiao1@huawei.com> - 3.2.2-2 * Thu Jul 9 2020 zhangqiumiao <zhangqiumiao1@huawei.com> - 3.2.2-2
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA