diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index c713bd2e3..b23031068 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -1246,7 +1246,8 @@ static struct volume_group *_read_vg(struct cmd_context *cmd, goto bad; } - if (!fixup_imported_mirrors(vg)) { + if (vg->fixup_imported_mirrors && + !fixup_imported_mirrors(vg)) { log_error("Failed to fixup mirror pointers after import for " "volume group %s.", vg->name); goto bad; diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c index b8668c18e..081072cb4 100644 --- a/lib/metadata/mirror.c +++ b/lib/metadata/mirror.c @@ -1367,11 +1367,12 @@ int fixup_imported_mirrors(struct volume_group *vg) { struct lv_list *lvl; struct lv_segment *seg; + const struct segment_type *mirror_segtype = + get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_MIRROR); dm_list_iterate_items(lvl, &vg->lvs) { dm_list_iterate_items(seg, &lvl->lv->segments) { - if (seg->segtype != - get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_MIRROR)) + if (seg->segtype != mirror_segtype) continue; if (seg->log_lv && !add_seg_to_segs_using_this_lv(seg->log_lv, seg)) diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h index e8fef29bc..2e1d95f38 100644 --- a/lib/metadata/vg.h +++ b/lib/metadata/vg.h @@ -46,6 +46,7 @@ struct volume_group { unsigned needs_backup : 1; unsigned needs_write_and_commit : 1; unsigned needs_lockd_free_lvs : 1; + unsigned fixup_imported_mirrors : 1; uint32_t write_count; /* count the number of vg_write calls */ uint32_t buffer_size_hint; /* hint with buffer size of parsed VG */ diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c index 072e17b3c..7e5834570 100644 --- a/lib/mirror/mirrored.c +++ b/lib/mirror/mirrored.c @@ -110,6 +110,7 @@ static int _mirrored_text_import(struct lv_segment *seg, const struct dm_config_ return 0; } seg->log_lv->status |= MIRROR_LOG; + seg->log_lv->vg->fixup_imported_mirrors = 1; } if (logname && !seg->region_size) {