|
Vojtech Trefny |
f0063a |
From 7a86d4306e3022b73035e21f66d515174264700e Mon Sep 17 00:00:00 2001
|
|
Vojtech Trefny |
f0063a |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
Vojtech Trefny |
f0063a |
Date: Thu, 9 Mar 2023 13:18:42 +0100
|
|
Vojtech Trefny |
f0063a |
Subject: [PATCH 1/2] Add support for specifying stripe size for RAID LVs
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
---
|
|
Vojtech Trefny |
f0063a |
blivet/devices/lvm.py | 28 +++++++++++++++++---
|
|
Vojtech Trefny |
f0063a |
tests/storage_tests/devices_test/lvm_test.py | 12 +++++++--
|
|
Vojtech Trefny |
f0063a |
tests/unit_tests/devices_test/lvm_test.py | 27 +++++++++++++++++++
|
|
Vojtech Trefny |
f0063a |
3 files changed, 61 insertions(+), 6 deletions(-)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
|
|
Vojtech Trefny |
f0063a |
index b8595d63..41358e9b 100644
|
|
Vojtech Trefny |
f0063a |
--- a/blivet/devices/lvm.py
|
|
Vojtech Trefny |
f0063a |
+++ b/blivet/devices/lvm.py
|
|
Vojtech Trefny |
f0063a |
@@ -659,7 +659,8 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
def __init__(self, name, parents=None, size=None, uuid=None, seg_type=None,
|
|
Vojtech Trefny |
f0063a |
fmt=None, exists=False, sysfs_path='', grow=None, maxsize=None,
|
|
Vojtech Trefny |
f0063a |
- percent=None, cache_request=None, pvs=None, from_lvs=None):
|
|
Vojtech Trefny |
f0063a |
+ percent=None, cache_request=None, pvs=None, from_lvs=None,
|
|
Vojtech Trefny |
f0063a |
+ stripe_size=0):
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
if not exists:
|
|
Vojtech Trefny |
f0063a |
if seg_type not in [None, "linear", "thin", "thin-pool", "cache", "vdo-pool", "vdo", "cache-pool"] + lvm.raid_seg_types:
|
|
Vojtech Trefny |
f0063a |
@@ -756,6 +757,15 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
|
|
Vojtech Trefny |
f0063a |
if self._pv_specs:
|
|
Vojtech Trefny |
f0063a |
self._assign_pv_space()
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ self._stripe_size = stripe_size
|
|
Vojtech Trefny |
f0063a |
+ if not self.exists and self._stripe_size:
|
|
Vojtech Trefny |
f0063a |
+ if self.seg_type not in lvm.raid_seg_types:
|
|
Vojtech Trefny |
f0063a |
+ raise errors.DeviceError("Stripe size can be specified only for RAID volumes")
|
|
Vojtech Trefny |
f0063a |
+ if self.seg_type in ("raid1", "RAID1", "1", 1, "mirror"):
|
|
Vojtech Trefny |
f0063a |
+ raise errors.DeviceError("Specifying stripe size is not allowed for RAID1 or mirror")
|
|
Vojtech Trefny |
f0063a |
+ if self.cache:
|
|
Vojtech Trefny |
f0063a |
+ raise errors.DeviceError("Creating cached LVs with custom stripe size is not supported")
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
def _assign_pv_space(self):
|
|
Vojtech Trefny |
f0063a |
if not self.is_raid_lv:
|
|
Vojtech Trefny |
f0063a |
# nothing to do for non-RAID (and thus non-striped) LVs here
|
|
Vojtech Trefny |
f0063a |
@@ -2295,7 +2305,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
|
|
Vojtech Trefny |
f0063a |
parent_lv=None, int_type=None, origin=None, vorigin=False,
|
|
Vojtech Trefny |
f0063a |
metadata_size=None, chunk_size=None, profile=None, from_lvs=None,
|
|
Vojtech Trefny |
f0063a |
compression=False, deduplication=False, index_memory=0,
|
|
Vojtech Trefny |
f0063a |
- write_policy=None, cache_mode=None, attach_to=None):
|
|
Vojtech Trefny |
f0063a |
+ write_policy=None, cache_mode=None, attach_to=None, stripe_size=0):
|
|
Vojtech Trefny |
f0063a |
"""
|
|
Vojtech Trefny |
f0063a |
:param name: the device name (generally a device node's basename)
|
|
Vojtech Trefny |
f0063a |
:type name: str
|
|
Vojtech Trefny |
f0063a |
@@ -2375,6 +2385,11 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
|
|
Vojtech Trefny |
f0063a |
be attached to when created
|
|
Vojtech Trefny |
f0063a |
:type attach_to: :class:`LVMLogicalVolumeDevice`
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ For RAID LVs only:
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
+ :keyword stripe_size: size of the RAID stripe
|
|
Vojtech Trefny |
f0063a |
+ :type stripe_size: :class:`~.size.Size`
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
"""
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
if isinstance(parents, (list, ParentList)):
|
|
Vojtech Trefny |
f0063a |
@@ -2395,7 +2410,8 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
|
|
Vojtech Trefny |
f0063a |
LVMCachePoolMixin.__init__(self, metadata_size, cache_mode, attach_to)
|
|
Vojtech Trefny |
f0063a |
LVMLogicalVolumeBase.__init__(self, name, parents, size, uuid, seg_type,
|
|
Vojtech Trefny |
f0063a |
fmt, exists, sysfs_path, grow, maxsize,
|
|
Vojtech Trefny |
f0063a |
- percent, cache_request, pvs, from_lvs)
|
|
Vojtech Trefny |
f0063a |
+ percent, cache_request, pvs, from_lvs,
|
|
Vojtech Trefny |
f0063a |
+ stripe_size)
|
|
Vojtech Trefny |
f0063a |
LVMVDOPoolMixin.__init__(self, compression, deduplication, index_memory,
|
|
Vojtech Trefny |
f0063a |
write_policy)
|
|
Vojtech Trefny |
f0063a |
LVMVDOLogicalVolumeMixin.__init__(self)
|
|
Vojtech Trefny |
f0063a |
@@ -2651,8 +2667,12 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
|
|
Vojtech Trefny |
f0063a |
pvs = [spec.pv.path for spec in self._pv_specs]
|
|
Vojtech Trefny |
f0063a |
pvs = pvs or None
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ extra = dict()
|
|
Vojtech Trefny |
f0063a |
+ if self._stripe_size:
|
|
Vojtech Trefny |
f0063a |
+ extra["stripesize"] = str(int(self._stripe_size.convert_to("KiB")))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
blockdev.lvm.lvcreate(self.vg.name, self._name, self.size,
|
|
Vojtech Trefny |
f0063a |
- type=self.seg_type, pv_list=pvs)
|
|
Vojtech Trefny |
f0063a |
+ type=self.seg_type, pv_list=pvs, **extra)
|
|
Vojtech Trefny |
f0063a |
else:
|
|
Vojtech Trefny |
f0063a |
fast_pvs = [pv.path for pv in self.cache.fast_pvs]
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
diff --git a/tests/storage_tests/devices_test/lvm_test.py b/tests/storage_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
index a055fc27..97ef1c4b 100644
|
|
Vojtech Trefny |
f0063a |
--- a/tests/storage_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
+++ b/tests/storage_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
@@ -1,4 +1,5 @@
|
|
Vojtech Trefny |
f0063a |
import os
|
|
Vojtech Trefny |
f0063a |
+import subprocess
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
from ..storagetestcase import StorageTestCase
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
@@ -127,7 +128,7 @@ class LVMTestCase(StorageTestCase):
|
|
Vojtech Trefny |
f0063a |
self.assertTrue(snap.is_snapshot_lv)
|
|
Vojtech Trefny |
f0063a |
self.assertEqual(snap.origin, thinlv)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
- def _test_lvm_raid(self, seg_type, raid_level):
|
|
Vojtech Trefny |
f0063a |
+ def _test_lvm_raid(self, seg_type, raid_level, stripe_size=0):
|
|
Vojtech Trefny |
f0063a |
disk1 = self.storage.devicetree.get_device_by_path(self.vdevs[0])
|
|
Vojtech Trefny |
f0063a |
self.assertIsNotNone(disk1)
|
|
Vojtech Trefny |
f0063a |
self.storage.initialize_disk(disk1)
|
|
Vojtech Trefny |
f0063a |
@@ -151,7 +152,7 @@ class LVMTestCase(StorageTestCase):
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
raidlv = self.storage.new_lv(fmt_type="ext4", size=blivet.size.Size("50 MiB"),
|
|
Vojtech Trefny |
f0063a |
parents=[vg], name="blivetTestRAIDLV",
|
|
Vojtech Trefny |
f0063a |
- seg_type=seg_type, pvs=[pv1, pv2])
|
|
Vojtech Trefny |
f0063a |
+ seg_type=seg_type, pvs=[pv1, pv2], stripe_size=stripe_size)
|
|
Vojtech Trefny |
f0063a |
self.storage.create_device(raidlv)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
self.storage.do_it()
|
|
Vojtech Trefny |
f0063a |
@@ -163,9 +164,16 @@ class LVMTestCase(StorageTestCase):
|
|
Vojtech Trefny |
f0063a |
self.assertEqual(raidlv.raid_level, raid_level)
|
|
Vojtech Trefny |
f0063a |
self.assertEqual(raidlv.seg_type, seg_type)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ if stripe_size:
|
|
Vojtech Trefny |
f0063a |
+ out = subprocess.check_output(["lvs", "-o", "stripe_size", "--noheadings", "--nosuffix", "--units=b", raidlv.vg.name + "/" + raidlv.lvname])
|
|
Vojtech Trefny |
f0063a |
+ self.assertEqual(out.decode().strip(), str(int(stripe_size.convert_to())))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
def test_lvm_raid_raid0(self):
|
|
Vojtech Trefny |
f0063a |
self._test_lvm_raid("raid0", blivet.devicelibs.raid.RAID0)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ def test_lvm_raid_raid0_stripe_size(self):
|
|
Vojtech Trefny |
f0063a |
+ self._test_lvm_raid("raid0", blivet.devicelibs.raid.RAID0, stripe_size=blivet.size.Size("1 MiB"))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
def test_lvm_raid_striped(self):
|
|
Vojtech Trefny |
f0063a |
self._test_lvm_raid("striped", blivet.devicelibs.raid.Striped)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
diff --git a/tests/unit_tests/devices_test/lvm_test.py b/tests/unit_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
index 995c2da4..d7b55224 100644
|
|
Vojtech Trefny |
f0063a |
--- a/tests/unit_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
+++ b/tests/unit_tests/devices_test/lvm_test.py
|
|
Vojtech Trefny |
f0063a |
@@ -363,6 +363,33 @@ class LVMDeviceTest(unittest.TestCase):
|
|
Vojtech Trefny |
f0063a |
self.assertEqual(pv.format.free, Size("264 MiB"))
|
|
Vojtech Trefny |
f0063a |
self.assertEqual(pv2.format.free, Size("256 MiB"))
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
+ def test_lvm_logical_volume_raid_stripe_size(self):
|
|
Vojtech Trefny |
f0063a |
+ pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"),
|
|
Vojtech Trefny |
f0063a |
+ size=Size("1025 MiB"))
|
|
Vojtech Trefny |
f0063a |
+ pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"),
|
|
Vojtech Trefny |
f0063a |
+ size=Size("513 MiB"))
|
|
Vojtech Trefny |
f0063a |
+ vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2])
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
+ with self.assertRaises(blivet.errors.DeviceError):
|
|
Vojtech Trefny |
f0063a |
+ # non-raid LV
|
|
Vojtech Trefny |
f0063a |
+ lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("1 GiB"),
|
|
Vojtech Trefny |
f0063a |
+ fmt=blivet.formats.get_format("xfs"),
|
|
Vojtech Trefny |
f0063a |
+ exists=False, stripe_size=Size("1 MiB"))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
+ with self.assertRaises(blivet.errors.DeviceError):
|
|
Vojtech Trefny |
f0063a |
+ # raid1 LV
|
|
Vojtech Trefny |
f0063a |
+ lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("1 GiB"),
|
|
Vojtech Trefny |
f0063a |
+ fmt=blivet.formats.get_format("xfs"),
|
|
Vojtech Trefny |
f0063a |
+ exists=False, seg_type="raid1", pvs=[pv, pv2],
|
|
Vojtech Trefny |
f0063a |
+ stripe_size=Size("1 MiB"))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
+ lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("1 GiB"),
|
|
Vojtech Trefny |
f0063a |
+ fmt=blivet.formats.get_format("xfs"),
|
|
Vojtech Trefny |
f0063a |
+ exists=False, seg_type="raid0", pvs=[pv, pv2],
|
|
Vojtech Trefny |
f0063a |
+ stripe_size=Size("1 MiB"))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
+ self.assertEqual(lv._stripe_size, Size("1 MiB"))
|
|
Vojtech Trefny |
f0063a |
+
|
|
Vojtech Trefny |
f0063a |
def test_target_size(self):
|
|
Vojtech Trefny |
f0063a |
pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"),
|
|
Vojtech Trefny |
f0063a |
size=Size("1 GiB"))
|
|
Vojtech Trefny |
f0063a |
--
|
|
Vojtech Trefny |
f0063a |
2.40.1
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
From bbfd1a70abe8271f5fe3d29fe2be3bb8a1c6ecbc Mon Sep 17 00:00:00 2001
|
|
Vojtech Trefny |
f0063a |
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
Vojtech Trefny |
f0063a |
Date: Wed, 3 May 2023 08:55:31 +0200
|
|
Vojtech Trefny |
f0063a |
Subject: [PATCH 2/2] Revert "tests: Skip test_lvcreate_type on CentOS/RHEL 9"
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
This reverts commit 16b90071145d2d0f19a38f3003561a0cc9d6e281.
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
The kernel issue was resolved, we no longer need to skip the test.
|
|
Vojtech Trefny |
f0063a |
---
|
|
Vojtech Trefny |
f0063a |
tests/skip.yml | 6 ------
|
|
Vojtech Trefny |
f0063a |
1 file changed, 6 deletions(-)
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
diff --git a/tests/skip.yml b/tests/skip.yml
|
|
Vojtech Trefny |
f0063a |
index 66b34493..c0ca0eaf 100644
|
|
Vojtech Trefny |
f0063a |
--- a/tests/skip.yml
|
|
Vojtech Trefny |
f0063a |
+++ b/tests/skip.yml
|
|
Vojtech Trefny |
f0063a |
@@ -24,12 +24,6 @@
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
---
|
|
Vojtech Trefny |
f0063a |
|
|
Vojtech Trefny |
f0063a |
-- test: storage_tests.devices_test.lvm_test.LVMTestCase.test_lvm_raid
|
|
Vojtech Trefny |
f0063a |
- skip_on:
|
|
Vojtech Trefny |
f0063a |
- - distro: "centos"
|
|
Vojtech Trefny |
f0063a |
- version: "9"
|
|
Vojtech Trefny |
f0063a |
- reason: "Creating RAID 1 LV on CentOS/RHEL 9 causes a system deadlock"
|
|
Vojtech Trefny |
f0063a |
-
|
|
Vojtech Trefny |
f0063a |
- test: storage_tests.formats_test.fs_test.XFSTestCase.test_resize
|
|
Vojtech Trefny |
f0063a |
skip_on:
|
|
Vojtech Trefny |
f0063a |
- distro: ["centos", "enterprise_linux"]
|
|
Vojtech Trefny |
f0063a |
--
|
|
Vojtech Trefny |
f0063a |
2.40.1
|
|
Vojtech Trefny |
f0063a |
|