]> sourceware.org Git - lvm2.git/commitdiff
lvconvert: preserve UUID on pool repair
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 14 Aug 2023 14:15:46 +0000 (16:15 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 14 Aug 2023 15:02:11 +0000 (17:02 +0200)
Once lvm2 repairs pool's metadata LV and preserves the original metadata LV
with unmodified metadata, for such LV in VG use newly created UUID for new
_pmspare and actually preserve UUID for this hidden _pmspare (if it
exists).

tools/lvconvert.c

index 953dea8a2eb003882eebddb073f14ec00326a953..5ea28675cf05215b1afb1e0b833941ca09422e7d 100644 (file)
@@ -2332,6 +2332,17 @@ static int _lvconvert_merge_thin_snapshot(struct cmd_context *cmd,
        return 1;
 }
 
+static void _swap_lv_uuid(struct logical_volume *lv1, struct logical_volume *lv2)
+{
+       union lvid lvid;
+
+       if (lv1 && lv2) {
+               lvid = lv1->lvid;
+               lv1->lvid = lv2->lvid;
+               lv2->lvid = lvid;
+       }
+}
+
 static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
                                       struct logical_volume *pool_lv,
                                       struct dm_list *pvh, int poolmetadataspare)
@@ -2500,6 +2511,9 @@ deactivate_pmslv:
        if (!lv_rename_update(cmd, mlv, pms_path, 0))
                return_0;
 
+       /* Preserve UUID for _pmspare if possible */
+       _swap_lv_uuid(mlv, mlv->vg->pool_metadata_spare_lv);
+
        if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
                return_0;
 
@@ -2657,6 +2671,9 @@ deactivate_pmslv:
        if (!lv_rename_update(cmd, mlv, pms_path, 0))
                return_0;
 
+       /* Preserve UUID for _pmspare if possible */
+       _swap_lv_uuid(mlv, mlv->vg->pool_metadata_spare_lv);
+
        if (!vg_write(cache_lv->vg) || !vg_commit(cache_lv->vg))
                return_0;
 
This page took 0.038596 seconds and 5 git commands to generate.