1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

import: check fixup mirror only when needed

Track whether import has even seen segment of LV with log_lv,
and call fixup mirror only in this case.

Also avoid repeated lookup of get_segtype_from_string for
SEG_TYPE_NAME_MIRROR.
This commit is contained in:
Zdenek Kabelac 2024-10-19 19:37:25 +02:00
parent 89da9ae251
commit 0179f00e0c
4 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -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))

View File

@ -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 */

View File

@ -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) {