lvm2/0008-raid-fix-name-rotation.patch

63 lines
2.1 KiB
Diff
Raw Permalink Normal View History

From 6e34a9e3959b659ac633d862af74c4c387a4d5ad Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Nov 2024 12:52:18 +0100
Subject: [PATCH 1/3] raid: fix name rotation
Since we now keep lv names valid all the time (as they are part
of radix_tree) - there is a problem with this renaming code, that
for a moment used duplicated name in vg struct.
Fix it by interating LVs backwared - which avoids breaking consitency
and also actually makes code more simple.
(cherry picked from commit c2f41c1a59351772b78f2328edd61f996cc37c3b)
---
lib/metadata/raid_manip.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 60ae897ef..8abad8be7 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -2637,6 +2637,7 @@ static int _raid_add_images_without_commit(struct logical_volume *lv,
struct lv_list *lvl;
struct lv_segment_area *new_areas;
struct segment_type *segtype;
+ const char *lv_name, *lv_name_tmp;
if (lv_is_not_synced(lv)) {
log_error("Can't add image to out-of-sync RAID LV:"
@@ -2704,22 +2705,14 @@ static int _raid_add_images_without_commit(struct logical_volume *lv,
* commits the LVM metadata before clearing the LVs.
*/
if (seg_is_linear(seg)) {
- struct dm_list *l;
- struct lv_list *lvl_tmp;
- const char *lv_name;
-
- dm_list_iterate(l, &data_lvs) {
- if (l == dm_list_last(&data_lvs)) {
- lvl = dm_list_item(l, struct lv_list);
- if (!(lv_name = _generate_raid_name(lv, "rimage", count)) ||
- !lv_set_name(lvl->lv, lv_name))
- return_0;
- continue;
- }
- lvl = dm_list_item(l, struct lv_list);
- lvl_tmp = dm_list_item(l->n, struct lv_list);
- if (!lv_set_name(lvl->lv, lvl_tmp->lv->name))
+ if (!(lv_name = _generate_raid_name(lv, "rimage", count)))
+ return_0;
+
+ dm_list_iterate_back_items(lvl, &data_lvs) {
+ lv_name_tmp = lvl->lv->name;
+ if (!lv_set_name(lvl->lv, lv_name))
return_0;
+ lv_name = lv_name_tmp; /* rotate name in list */
}
}
--
2.47.0