diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index dd1219b99..9aac6e9fc 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -483,7 +483,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna _pv_populate_lvmcache(cmd, pvcn, fmt, 0); top->key = name; - if (!(vg = import_vg_from_config_tree(reply.cft, fid))) + if (!(vg = import_vg_from_lvmetad_config_tree(reply.cft, fid))) goto_out; dm_list_iterate_items(pvl, &vg->pvs) { diff --git a/lib/format_text/import-export.h b/lib/format_text/import-export.h index 1ee647ba5..f60496fe5 100644 --- a/lib/format_text/import-export.h +++ b/lib/format_text/import-export.h @@ -47,7 +47,8 @@ struct text_vg_version_ops { int (*check_version) (const struct dm_config_tree * cf); struct volume_group *(*read_vg) (struct format_instance * fid, const struct dm_config_tree *cf, - unsigned use_cached_pvs); + unsigned use_cached_pvs, + unsigned allow_lvmetad_extensions); void (*read_desc) (struct dm_pool * mem, const struct dm_config_tree *cf, time_t *when, char **desc); int (*read_vgname) (const struct format_type *fmt, diff --git a/lib/format_text/import.c b/lib/format_text/import.c index 84230cb35..16cdf9b82 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -146,7 +146,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid, if (!(*vsn)->check_version(cft)) continue; - if (!(vg = (*vsn)->read_vg(fid, cft, single_device))) + if (!(vg = (*vsn)->read_vg(fid, cft, single_device, 0))) goto_out; (*vsn)->read_desc(vg->vgmem, cft, when, desc); @@ -174,8 +174,9 @@ struct volume_group *text_vg_import_file(struct format_instance *fid, when, desc); } -struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft, - struct format_instance *fid) +static struct volume_group *_import_vg_from_config_tree(const struct dm_config_tree *cft, + struct format_instance *fid, + unsigned allow_lvmetad_extensions) { struct volume_group *vg = NULL; struct text_vg_version_ops **vsn; @@ -190,7 +191,7 @@ struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft * The only path to this point uses cached vgmetadata, * so it can use cached PV state too. */ - if (!(vg = (*vsn)->read_vg(fid, cft, 1))) + if (!(vg = (*vsn)->read_vg(fid, cft, 1, allow_lvmetad_extensions))) stack; else if ((vg_missing = vg_missing_pv_count(vg))) { log_verbose("There are %d physical volumes missing.", @@ -203,3 +204,15 @@ struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft return vg; } + +struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft, + struct format_instance *fid) +{ + return _import_vg_from_config_tree(cft, fid, 0); +} + +struct volume_group *import_vg_from_lvmetad_config_tree(const struct dm_config_tree *cft, + struct format_instance *fid) +{ + return _import_vg_from_config_tree(cft, fid, 1); +} diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index 2d629052c..048c8fe63 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -740,7 +740,8 @@ static int _read_sections(struct format_instance *fid, static struct volume_group *_read_vg(struct format_instance *fid, const struct dm_config_tree *cft, - unsigned use_cached_pvs) + unsigned use_cached_pvs, + unsigned allow_lvmetad_extensions) { const struct dm_config_node *vgn; const struct dm_config_value *cv; @@ -882,8 +883,11 @@ static struct volume_group *_read_vg(struct format_instance *fid, goto bad; } - _read_sections(fid, "outdated_pvs", _read_pv, vg, - vgn, pv_hash, lv_hash, 1, &scan_done_once); + if (allow_lvmetad_extensions) + _read_sections(fid, "outdated_pvs", _read_pv, vg, + vgn, pv_hash, lv_hash, 1, &scan_done_once); + else if (dm_config_has_node(vgn, "outdated_pvs")) + log_error(INTERNAL_ERROR "Unexpected outdated_pvs section in metadata of VG %s.", vg->name); /* Optional tags */ if (dm_config_get_list(vgn, "tags", &cv) && diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 031d19e5f..abf60726f 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -460,6 +460,8 @@ struct volume_group *import_vg_from_buffer(const char *buf, struct format_instance *fid); struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft, struct format_instance *fid); +struct volume_group *import_vg_from_lvmetad_config_tree(const struct dm_config_tree *cft, + struct format_instance *fid); /* * Mirroring functions