From 3d02e22649c6d127ae32ff1b527ad53a7704f4f3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 10 2021 04:24:54 +0000 Subject: import python-blivet-3.4.0-4.el8 --- diff --git a/SOURCES/0006-Fix-resolving-devices-with-names-that-look-like-BIOS.patch b/SOURCES/0006-Fix-resolving-devices-with-names-that-look-like-BIOS.patch new file mode 100644 index 0000000..28c7351 --- /dev/null +++ b/SOURCES/0006-Fix-resolving-devices-with-names-that-look-like-BIOS.patch @@ -0,0 +1,75 @@ +From 344e624f91010b6041c22ee8a24c9305b82af969 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 18 May 2021 12:54:02 +0200 +Subject: [PATCH] Fix resolving devices with names that look like BIOS drive + number + +A RAID array named "10" will not be resolved because we try to +resolve it using EDD data and after this lookup fails, we don't +try the name. + +Resolves: rhbz#1960798 +--- + blivet/devicetree.py | 18 +++++++++--------- + tests/devicetree_test.py | 4 ++++ + 2 files changed, 13 insertions(+), 9 deletions(-) + +diff --git a/blivet/devicetree.py b/blivet/devicetree.py +index 88e9f0e5..f4ae1968 100644 +--- a/blivet/devicetree.py ++++ b/blivet/devicetree.py +@@ -634,20 +634,20 @@ class DeviceTreeBase(object): + (label.startswith("'") and label.endswith("'"))): + label = label[1:-1] + device = self.labels.get(label) +- elif re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec): +- # BIOS drive number +- (drive, _p, partnum) = devspec.partition("p") +- spec = int(drive, 16) +- for (edd_name, edd_number) in self.edd_dict.items(): +- if edd_number == spec: +- device = self.get_device_by_name(edd_name + partnum) +- break + elif options and "nodev" in options.split(","): + device = self.get_device_by_name(devspec) + if not device: + device = self.get_device_by_path(devspec) + else: +- if not devspec.startswith("/dev/"): ++ if re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec): ++ # BIOS drive number ++ (drive, _p, partnum) = devspec.partition("p") ++ spec = int(drive, 16) ++ for (edd_name, edd_number) in self.edd_dict.items(): ++ if edd_number == spec: ++ device = self.get_device_by_name(edd_name + partnum) ++ break ++ if not device and not devspec.startswith("/dev/"): + device = self.get_device_by_name(devspec) + if not device: + devspec = "/dev/" + devspec +diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py +index 11f8469d..b033343d 100644 +--- a/tests/devicetree_test.py ++++ b/tests/devicetree_test.py +@@ -49,6 +49,9 @@ class DeviceTreeTestCase(unittest.TestCase): + dev3 = StorageDevice("sdp2", exists=True) + dt._add_device(dev3) + ++ dev4 = StorageDevice("10", exists=True) ++ dt._add_device(dev4) ++ + dt.edd_dict.update({"dev1": 0x81, + "dev2": 0x82}) + +@@ -62,6 +65,7 @@ class DeviceTreeTestCase(unittest.TestCase): + self.assertEqual(dt.resolve_device("0x82"), dev2) + + self.assertEqual(dt.resolve_device(dev3.name), dev3) ++ self.assertEqual(dt.resolve_device(dev4.name), dev4) + + def test_device_name(self): + # check that devicetree.names property contains all device's names +-- +2.31.1 + diff --git a/SOURCES/0007-Do-not-set-chunk-size-for-RAID1.patch b/SOURCES/0007-Do-not-set-chunk-size-for-RAID1.patch new file mode 100644 index 0000000..2b40cfa --- /dev/null +++ b/SOURCES/0007-Do-not-set-chunk-size-for-RAID1.patch @@ -0,0 +1,151 @@ +From dc1e2fe7783748528cac2f7aa516c89d1959b052 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Thu, 29 Jul 2021 14:44:22 +0200 +Subject: [PATCH] Do not set chunk size for RAID 1 + +Setting chunk size for RAID 1 doesn't make sense and latest +mdadm started returning error instead of ignoring the --chunk +option when creating an array. + +Resolves: rhbz#1987170 +--- + blivet/devicelibs/raid.py | 12 ++++++++++ + blivet/devices/md.py | 15 ++++++++++--- + tests/devices_test/md_test.py | 41 +++++++++++++++++++++++++++++++++-- + 3 files changed, 63 insertions(+), 5 deletions(-) + +diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py +index 19c3fae98..a9e241c7a 100644 +--- a/blivet/devicelibs/raid.py ++++ b/blivet/devicelibs/raid.py +@@ -462,6 +462,18 @@ def _pad(self, size, chunk_size): + def _get_recommended_stride(self, member_count): + return None + ++ def get_size(self, member_sizes, num_members=None, chunk_size=None, superblock_size_func=None): ++ if not member_sizes: ++ return Size(0) ++ ++ if num_members is None: ++ num_members = len(member_sizes) ++ ++ min_size = min(member_sizes) ++ superblock_size = superblock_size_func(min_size) ++ min_data_size = self._trim(min_size - superblock_size, chunk_size) ++ return self.get_net_array_size(num_members, min_data_size) ++ + + RAID1 = RAID1() + ALL_LEVELS.add_raid_level(RAID1) +diff --git a/blivet/devices/md.py b/blivet/devices/md.py +index 69eee93a5..d1a2faf1f 100644 +--- a/blivet/devices/md.py ++++ b/blivet/devices/md.py +@@ -138,7 +138,7 @@ def __init__(self, name, level=None, major=None, minor=None, size=None, + if self.exists: + self._chunk_size = self.read_chunk_size() + else: +- self._chunk_size = chunk_size or mdraid.MD_CHUNK_SIZE ++ self.chunk_size = chunk_size or Size(0) + + if not self.exists and not isinstance(metadata_version, str): + self.metadata_version = "default" +@@ -208,8 +208,14 @@ def sector_size(self): + + @property + def chunk_size(self): +- if self.exists and self._chunk_size == Size(0): +- self._chunk_size = self.read_chunk_size() ++ if self._chunk_size == Size(0): ++ if self.exists: ++ return self.read_chunk_size() ++ else: ++ if self.level == raid.RAID1: ++ return self._chunk_size ++ else: ++ return mdraid.MD_CHUNK_SIZE + return self._chunk_size + + @chunk_size.setter +@@ -223,6 +229,9 @@ def chunk_size(self, newsize): + if self.exists: + raise ValueError("cannot set chunk size for an existing device") + ++ if self.level == raid.RAID1 and newsize != Size(0): ++ raise ValueError("specifying chunk size is not allowed for raid1") ++ + self._chunk_size = newsize + + def read_chunk_size(self): +diff --git a/tests/devices_test/md_test.py b/tests/devices_test/md_test.py +index 46df76d3d..47a0fa0cc 100644 +--- a/tests/devices_test/md_test.py ++++ b/tests/devices_test/md_test.py +@@ -1,6 +1,11 @@ + import six + import unittest + ++try: ++ from unittest.mock import patch ++except ImportError: ++ from mock import patch ++ + import blivet + + from blivet.devices import StorageDevice +@@ -27,9 +32,27 @@ def test_chunk_size1(self): + raid_array = MDRaidArrayDevice(name="raid", level="raid0", member_devices=2, + total_devices=2, parents=[member1, member2]) + +- # no chunk_size specified -- default value ++ # no chunk_size specified and RAID0 -- default value + self.assertEqual(raid_array.chunk_size, mdraid.MD_CHUNK_SIZE) + ++ with patch("blivet.devices.md.blockdev.md.create") as md_create: ++ raid_array._create() ++ md_create.assert_called_with("/dev/md/raid", "raid0", ["/dev/member1", "/dev/member2"], ++ 0, version="default", bitmap=False, ++ chunk_size=mdraid.MD_CHUNK_SIZE) ++ ++ raid_array = MDRaidArrayDevice(name="raid", level="raid1", member_devices=2, ++ total_devices=2, parents=[member1, member2]) ++ ++ # no chunk_size specified and RAID1 -- no chunk size set (0) ++ self.assertEqual(raid_array.chunk_size, Size(0)) ++ ++ with patch("blivet.devices.md.blockdev.md.create") as md_create: ++ raid_array._create() ++ md_create.assert_called_with("/dev/md/raid", "raid1", ["/dev/member1", "/dev/member2"], ++ 0, version="default", bitmap=True, ++ chunk_size=0) ++ + def test_chunk_size2(self): + + member1 = StorageDevice("member1", fmt=blivet.formats.get_format("mdmember"), +@@ -40,11 +63,25 @@ def test_chunk_size2(self): + raid_array = MDRaidArrayDevice(name="raid", level="raid0", member_devices=2, + total_devices=2, parents=[member1, member2], + chunk_size=Size("1024 KiB")) +- + self.assertEqual(raid_array.chunk_size, Size("1024 KiB")) + ++ # for raid0 setting chunk_size = 0 means "default" ++ raid_array.chunk_size = Size(0) ++ self.assertEqual(raid_array.chunk_size, mdraid.MD_CHUNK_SIZE) ++ + with six.assertRaisesRegex(self, ValueError, "new chunk size must be of type Size"): + raid_array.chunk_size = 1 + + with six.assertRaisesRegex(self, ValueError, "new chunk size must be multiple of 4 KiB"): + raid_array.chunk_size = Size("5 KiB") ++ ++ with six.assertRaisesRegex(self, ValueError, "specifying chunk size is not allowed for raid1"): ++ MDRaidArrayDevice(name="raid", level="raid1", member_devices=2, ++ total_devices=2, parents=[member1, member2], ++ chunk_size=Size("1024 KiB")) ++ ++ raid_array = MDRaidArrayDevice(name="raid", level="raid1", member_devices=2, ++ total_devices=2, parents=[member1, member2]) ++ ++ with six.assertRaisesRegex(self, ValueError, "specifying chunk size is not allowed for raid1"): ++ raid_array.chunk_size = Size("512 KiB") diff --git a/SPECS/python-blivet.spec b/SPECS/python-blivet.spec index 86dd5f8..8bca215 100644 --- a/SPECS/python-blivet.spec +++ b/SPECS/python-blivet.spec @@ -23,7 +23,7 @@ Version: 3.4.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 2%{?prerelease}%{?dist} +Release: 4%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ %global realname blivet @@ -35,6 +35,8 @@ Patch1: 0002-remove-btrfs-plugin.patch Patch2: 0003-Revert-More-consistent-lvm-errors.patch Patch3: 0004-Revert-Terminology-cleanups.patch Patch4: 0005-Fix-activating-old-style-LVM-snapshots.patch +Patch5: 0006-Fix-resolving-devices-with-names-that-look-like-BIOS.patch +Patch6: 0007-Do-not-set-chunk-size-for-RAID1.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -197,6 +199,14 @@ configuration. %endif %changelog +* Mon Aug 2 2021 Vojtech Trefny - 3.4.0-4 +- Do not set chunk size for RAID 1 + Resolves: rhbz#1987170 + +* Wed Jul 21 2021 Vojtech Trefny - 3.4.0-3 +- Fix resolving devices with names that look like BIOS drive number + Resolves: rhbz#1983309 + * Wed Jul 7 2021 Vojtech Trefny - 3.4.0-2 - Fix activating old style LVM snapshots Resolves: rhbz#1961739