Blame SOURCES/Bug-2098226-storage-role-raid_level-striped-is-not-supported.patch

3754e5
From acb99e74a24fa07863c596fe59d2999adc28c249 Mon Sep 17 00:00:00 2001
3754e5
From: Vojtech Trefny <vtrefny@redhat.com>
3754e5
Date: Thu, 2 Jun 2022 15:18:19 +0200
3754e5
Subject: [PATCH] LVM RAID raid0 level support (#272)
3754e5
3754e5
* Add workaround for missing LVM raid0 support in blivet
3754e5
3754e5
Blivet supports creating LVs with segment type "raid0" but it is
3754e5
not in the list of supported RAID levels. This will be fixed in
3754e5
blivet, see https://github.com/storaged-project/blivet/pull/1047
3754e5
3754e5
* Add a test for LVM RAID raid0 level
3754e5
3754e5
* README: Remove "striped" from the list of supported RAID for pools
3754e5
3754e5
We use MD RAID for RAIDs on the pool level which doesn't support
3754e5
"striped" level.
3754e5
3754e5
* README: Clarify supported volume RAID levels
3754e5
3754e5
We support different levels for LVM RAID and MD RAID.
3754e5
3754e5
(cherry picked from commit 8b868a348155b08479743945aba88271121ad4b0)
3754e5
---
3754e5
 README.md                                    |  7 ++-
3754e5
 library/blivet.py                            |  7 +++
3754e5
 tests/tests_create_raid_pool_then_remove.yml | 54 ++++++++++++++++++++
3754e5
 3 files changed, 66 insertions(+), 2 deletions(-)
3754e5
3754e5
diff --git a/README.md b/README.md
3754e5
index f8e3daa..bd123d7 100644
3754e5
--- a/README.md
3754e5
+++ b/README.md
3754e5
@@ -54,7 +54,7 @@ device node basename (like `sda` or `mpathb`), /dev/disk/ symlink
3754e5
 ##### `raid_level`
3754e5
 When used with `type: lvm` it manages a volume group with a mdraid array of given level
3754e5
 on it. Input `disks` are in this case used as RAID members.
3754e5
-Accepted values are: `linear`, `striped`, `raid0`, `raid1`, `raid4`, `raid5`, `raid6`, `raid10`
3754e5
+Accepted values are: `linear`, `raid0`, `raid1`, `raid4`, `raid5`, `raid6`, `raid10`
3754e5
 
3754e5
 ##### `volumes`
3754e5
 This is a list of volumes that belong to the current pool. It follows the
3754e5
@@ -136,7 +136,10 @@ Specifies RAID level. LVM RAID can be created as well.
3754e5
 "Regular" RAID volume requires type to be `raid`.
3754e5
 LVM RAID needs that volume has `storage_pools` parent with type `lvm`,
3754e5
 `raid_disks` need to be specified as well.
3754e5
-Accepted values are: `linear` (N/A for LVM RAID), `striped`, `raid0`, `raid1`, `raid4`, `raid5`, `raid6`, `raid10`
3754e5
+Accepted values are:
3754e5
+* for LVM RAID volume: `raid0`, `raid1`, `raid4`, `raid5`, `raid6`, `raid10`, `striped`, `mirror`
3754e5
+* for RAID volume: `linear`, `raid0`, `raid1`, `raid4`, `raid5`, `raid6`, `raid10`
3754e5
+
3754e5
 __WARNING__: Changing `raid_level` for a volume is a destructive operation, meaning
3754e5
              all data on that volume will be lost as part of the process of
3754e5
              removing old and adding new RAID. RAID reshaping is currently not
3754e5
diff --git a/library/blivet.py b/library/blivet.py
3754e5
index 29552fa..33c93b2 100644
3754e5
--- a/library/blivet.py
3754e5
+++ b/library/blivet.py
3754e5
@@ -118,6 +118,7 @@ LIB_IMP_ERR = ""
3754e5
 try:
3754e5
     from blivet3 import Blivet
3754e5
     from blivet3.callbacks import callbacks
3754e5
+    from blivet3 import devicelibs
3754e5
     from blivet3 import devices
3754e5
     from blivet3.deviceaction import ActionConfigureFormat
3754e5
     from blivet3.flags import flags as blivet_flags
3754e5
@@ -132,6 +133,7 @@ except ImportError:
3754e5
     try:
3754e5
         from blivet import Blivet
3754e5
         from blivet.callbacks import callbacks
3754e5
+        from blivet import devicelibs
3754e5
         from blivet import devices
3754e5
         from blivet.deviceaction import ActionConfigureFormat
3754e5
         from blivet.flags import flags as blivet_flags
3754e5
@@ -152,6 +154,11 @@ if BLIVET_PACKAGE:
3754e5
     set_up_logging()
3754e5
     log = logging.getLogger(BLIVET_PACKAGE + ".ansible")
3754e5
 
3754e5
+    # XXX add support for LVM RAID raid0 level
3754e5
+    devicelibs.lvm.raid_levels.add_raid_level(devicelibs.raid.RAID0)
3754e5
+    if "raid0" not in devicelibs.lvm.raid_seg_types:
3754e5
+        devicelibs.lvm.raid_seg_types.append("raid0")
3754e5
+
3754e5
 
3754e5
 MAX_TRIM_PERCENT = 2
3754e5
 
3754e5
diff --git a/tests/tests_create_raid_pool_then_remove.yml b/tests/tests_create_raid_pool_then_remove.yml
3754e5
index d81680d..1fb4e15 100644
3754e5
--- a/tests/tests_create_raid_pool_then_remove.yml
3754e5
+++ b/tests/tests_create_raid_pool_then_remove.yml
3754e5
@@ -150,3 +150,57 @@
3754e5
                 raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
3754e5
 
3754e5
     - include_tasks: verify-role-results.yml
3754e5
+
3754e5
+    - name: Create a RAID0 lvm raid device
3754e5
+      include_role:
3754e5
+        name: linux-system-roles.storage
3754e5
+      vars:
3754e5
+        storage_pools:
3754e5
+          - name: vg1
3754e5
+            disks: "{{ unused_disks }}"
3754e5
+            type: lvm
3754e5
+            state: present
3754e5
+            volumes:
3754e5
+              - name: lv1
3754e5
+                size: "{{ volume1_size }}"
3754e5
+                mount_point: "{{ mount_location1 }}"
3754e5
+                raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
3754e5
+                raid_level: raid0
3754e5
+
3754e5
+    - include_tasks: verify-role-results.yml
3754e5
+
3754e5
+    - name: Repeat the previous invocation to verify idempotence
3754e5
+      include_role:
3754e5
+        name: linux-system-roles.storage
3754e5
+      vars:
3754e5
+        storage_pools:
3754e5
+          - name: vg1
3754e5
+            disks: "{{ unused_disks }}"
3754e5
+            type: lvm
3754e5
+            state: present
3754e5
+            volumes:
3754e5
+              - name: lv1
3754e5
+                size: "{{ volume1_size }}"
3754e5
+                mount_point: "{{ mount_location1 }}"
3754e5
+                raid_level: raid0
3754e5
+                raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
3754e5
+
3754e5
+    - include_tasks: verify-role-results.yml
3754e5
+
3754e5
+    - name: Remove the device created above
3754e5
+      include_role:
3754e5
+        name: linux-system-roles.storage
3754e5
+      vars:
3754e5
+        storage_pools:
3754e5
+          - name: vg1
3754e5
+            disks: "{{ unused_disks }}"
3754e5
+            type: lvm
3754e5
+            state: absent
3754e5
+            volumes:
3754e5
+              - name: lv1
3754e5
+                size: "{{ volume1_size }}"
3754e5
+                mount_point: "{{ mount_location1 }}"
3754e5
+                raid_level: raid0
3754e5
+                raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
3754e5
+
3754e5
+    - include_tasks: verify-role-results.yml
3754e5
-- 
3754e5
2.35.3
3754e5