diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index 7aa864122..6c8b10b75 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -425,26 +425,6 @@ static int _fixup_ignored(struct metadata_area *mda, void *baton) { return 1; } -static struct dm_config_tree *_export_vg_to_config_tree(struct volume_group *vg) -{ - char *buf = NULL; - struct dm_config_tree *vgmeta; - - if (!export_vg_to_buffer(vg, &buf)) { - log_error("Could not format VG metadata."); - return 0; - } - - if (!(vgmeta = dm_config_from_string(buf))) { - log_error("Error parsing VG metadata."); - dm_free(buf); - return 0; - } - - dm_free(buf); - return vgmeta; -} - int lvmetad_vg_update(struct volume_group *vg) { daemon_reply reply; @@ -462,7 +442,7 @@ int lvmetad_vg_update(struct volume_group *vg) if (!lvmetad_active() || test_mode()) return 1; /* fake it */ - if (!(vgmeta = _export_vg_to_config_tree(vg))) + if (!(vgmeta = export_vg_to_config_tree(vg))) return_0; log_debug_lvmetad("Sending lvmetad updated metadata for VG %s (seqno %" PRIu32 ")", vg->name, vg->seqno); @@ -772,7 +752,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for _extract_mdas(info, pvmeta, pvmeta->root); if (vg) { - if (!(vgmeta = _export_vg_to_config_tree(vg))) { + if (!(vgmeta = export_vg_to_config_tree(vg))) { dm_config_destroy(pvmeta); return_0; } diff --git a/lib/format_text/export.c b/lib/format_text/export.c index 73b5a3ad2..b6aac456b 100644 --- a/lib/format_text/export.c +++ b/lib/format_text/export.c @@ -841,5 +841,25 @@ size_t export_vg_to_buffer(struct volume_group *vg, char **buf) return text_vg_export_raw(vg, "", buf); } +struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg) +{ + char *buf = NULL; + struct dm_config_tree *vg_cft; + + if (!export_vg_to_buffer(vg, &buf)) { + log_error("Could not format metadata for VG %s.", vg->name); + return_NULL; + } + + if (!(vg_cft = dm_config_from_string(buf))) { + log_error("Error parsing metadata for VG %s.", vg->name); + dm_free(buf); + return_NULL; + } + + dm_free(buf); + return vg_cft; +} + #undef outf #undef outnl diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 4f504ed79..bf9bd55ec 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -437,7 +437,7 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea * For internal metadata caching. */ size_t export_vg_to_buffer(struct volume_group *vg, char **buf); -int export_vg_to_config_tree(struct volume_group *vg, struct dm_config_tree **cft); +struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg); 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,