master - metadata: Reject lvmetad metadata extensions when reading from disk.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c78b6f18d4909dc4e5c873b3b1023c2053443046 Commit: c78b6f18d4909dc4e5c873b3b1023c2053443046 Parent: 4f91ad64c3c76ab31efe6bfad362adefd47adff2 Author: Petr Rockai <[email protected]> AuthorDate: Wed Jun 10 16:25:57 2015 +0200 Committer: Petr Rockai <[email protected]> CommitterDate: Wed Jun 10 16:25:57 2015 +0200
metadata: Reject lvmetad metadata extensions when reading from disk.
--- lib/cache/lvmetad.c | 2 +- lib/format_text/import-export.h | 3 ++- lib/format_text/import.c | 21 +++++++++++++++++---- lib/format_text/import_vsn1.c | 10 +++++++--- lib/metadata/metadata.h | 2 ++ 5 files changed, 29 insertions(+), 9 deletions(-)
lib/cache/lvmetad.c +1 -1
@@ -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) {
lib/format_text/import-export.h +2 -1
@@ -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,
lib/format_text/import.c +17 -4
@@ -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 *cftreturn 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 ); +}
lib/format_text/import_vsn1.c +7 -3
@@ -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) &&
lib/metadata/metadata.h +2 -0
@@ -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