From e8d00e068762d0ebd7dd489d45c43927b7ffdc58 Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Wed, 29 Apr 2015 15:01:20 +0200 Subject: [PATCH] lvmetad: Set up lvmcache & PV structs for outdated_pvs. --- lib/cache/lvmetad.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index a66f91548..68162b65e 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -395,6 +395,22 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd, return 1; } +static int _pv_update_struct_pv(struct physical_volume *pv, struct format_instance *fid) +{ + struct lvmcache_info *info; + if ((info = lvmcache_info_from_pvid((const char *)&pv->id, 0))) { + pv->label_sector = lvmcache_get_label(info)->sector; + pv->dev = lvmcache_device(info); + if (!pv->dev) + pv->status |= MISSING_PV; + if (!lvmcache_fid_add_mdas_pv(info, fid)) + return_0; + pv->fid = fid; + } else + pv->status |= MISSING_PV; /* probably missing */ + return 1; +} + struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgname, const char *vgid) { struct volume_group *vg = NULL; @@ -409,7 +425,6 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna struct format_type *fmt; struct dm_config_node *pvcn; struct pv_list *pvl; - struct lvmcache_info *info; if (!lvmetad_active()) return NULL; @@ -460,22 +475,26 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna for (pvcn = pvcn->child; pvcn; pvcn = pvcn->sib) _pv_populate_lvmcache(cmd, pvcn, fmt, 0); + if ((pvcn = dm_config_find_node(top, "metadata/outdated_pvs"))) + for (pvcn = pvcn->child; pvcn; pvcn = pvcn->sib) + _pv_populate_lvmcache(cmd, pvcn, fmt, 0); + top->key = name; if (!(vg = import_vg_from_config_tree(reply.cft, fid))) goto_out; dm_list_iterate_items(pvl, &vg->pvs) { - if ((info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0))) { - pvl->pv->label_sector = lvmcache_get_label(info)->sector; - pvl->pv->dev = lvmcache_device(info); - if (!pvl->pv->dev) - pvl->pv->status |= MISSING_PV; - if (!lvmcache_fid_add_mdas_pv(info, fid)) { - vg = NULL; - goto_out; /* FIXME error path */ - } - } else - pvl->pv->status |= MISSING_PV; /* probably missing */ + if (!_pv_update_struct_pv(pvl->pv, fid)) { + vg = NULL; + goto_out; /* FIXME error path */ + } + } + + dm_list_iterate_items(pvl, &vg->pvs_outdated) { + if (!_pv_update_struct_pv(pvl->pv, fid)) { + vg = NULL; + goto_out; /* FIXME error path */ + } } lvmcache_update_vg(vg, 0);