From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 425 invoked by alias); 20 Jul 2011 16:46:42 -0000 Received: (qmail 407 invoked by uid 9699); 20 Jul 2011 16:46:41 -0000 Date: Wed, 20 Jul 2011 16:46:00 -0000 Message-ID: <20110720164641.405.qmail@sourceware.org> From: mornfall@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/daemons/lvmetad lvmetad-core.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00046.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-07-20 16:46:40 Modified files: daemons/lvmetad: lvmetad-core.c Log message: Make lvmetad also report VGID in reply when adding a PV without MDAs (this obviously only works for VGs that already had at least some MDA discovered). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/07/20 15:14:17 1.10 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/07/20 16:46:40 1.11 @@ -83,12 +83,17 @@ } } -static void update_pv_status_in_vg(lvmetad_state *s, struct config_tree *vg) +struct config_node *pvs(struct config_tree *vg) { struct config_node *pv = find_config_node(vg->root, "metadata/physical_volumes"); if (pv) pv = pv->child; + return pv; +} +static void update_pv_status_in_vg(lvmetad_state *s, struct config_tree *vg) +{ + struct config_node *pv = pvs(vg); while (pv) { const char *uuid = find_config_str(pv->child, "id", "N/A"); const char *vgid = find_config_str(vg->root, "metadata/id", "N/A"); @@ -101,9 +106,7 @@ static int vg_status(lvmetad_state *s, const char *vgid) { struct config_tree *vg = dm_hash_lookup(s->vgs, vgid); - struct config_node *pv = find_config_node(vg->root, "metadata/physical_volumes"); - if (pv) - pv = pv->child; + struct config_node *pv = pvs(vg); while (pv) { const char *uuid = find_config_str(pv->child, "id", "N/A"); @@ -141,6 +144,26 @@ } } +struct config_tree *vg_from_pvid(lvmetad_state *s, const char *pvid) +{ + struct dm_hash_node *n = dm_hash_get_first(s->vgs); + + while (n) { + struct config_tree *vg = dm_hash_get_data(s->vgs, n); + struct config_node *pv = pvs(vg); + + while (pv) { + const char *uuid = find_config_str(pv->child, "id", "N/A"); + if (!strcmp(uuid, pvid)) + return vg; + pv = pv->sib; + } + + n = dm_hash_get_next(s->vgs, n); + } + return NULL; +} + static int update_metadata(lvmetad_state *s, const char *vgid, struct config_node *metadata) { struct config_tree *old = dm_hash_lookup(s->vgs, vgid); @@ -198,8 +221,9 @@ return daemon_reply_simple("failed", "reason = %s", "metadata update failed", NULL); } else { - // TODO: find the corresponding VGID when available to give to - // the caller, and to find out whether the VG is complete + struct config_tree *vg = vg_from_pvid(s, pvid); + if (vg) + vgid = find_config_str(vg->root, "metadata/id", NULL); } update_pv_status(s, NULL); @@ -207,7 +231,7 @@ return daemon_reply_simple("OK", "status = %s", complete ? "complete" : "partial", - vgid ? "vgid = %s" : "", vgid, + "vgid = %s", vgid ? vgid : "#orphan", NULL); }