]> sourceware.org Git - lvm2.git/commitdiff
cope with volatile vginfo in vg_read
authorAlasdair Kergon <agk@redhat.com>
Fri, 6 Jun 2008 11:12:50 +0000 (11:12 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 6 Jun 2008 11:12:50 +0000 (11:12 +0000)
lib/cache/lvmcache.c
lib/metadata/metadata.c

index 33b029566916eac3be729fe0ffbbb20efaf3e66a..77382d4c35f7f3add9fa25c910f7aa61ab284839 100644 (file)
@@ -243,6 +243,9 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname, const char *vgid)
 {
        struct lvmcache_vginfo *vginfo;
 
+       if (!vgname)
+               return vginfo_from_vgid(vgid);
+
        if (!_vgname_hash)
                return NULL;
 
index ff05d7c12f7e35e64d31486696ea63f119565a37..d385814a8eef010ad61ee7bcbf32d243d6bfb2aa 100644 (file)
@@ -1476,6 +1476,8 @@ static int _update_pv_list(struct list *all_pvs, struct volume_group *vg)
  * and call vg_read again).
  *
  * If precommitted is set, use precommitted metadata if present.
+ *
+ * Either of vgname or vgid may be NULL.
  */
 static struct volume_group *_vg_read(struct cmd_context *cmd,
                                     const char *vgname,
@@ -1522,6 +1524,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
                }
        }
 
+       /* Now determine the correct vgname if none was supplied */
+       if (!vgname && !(vgname = vgname_from_vgid(cmd->mem, vgid)))
+               return_NULL;
+
        if (use_precommitted && !(fmt->features & FMT_PRECOMMIT))
                use_precommitted = 0;
 
@@ -1752,7 +1758,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
        /* Is corresponding vgname already cached? */
        if ((vginfo = vginfo_from_vgid(vgid)) &&
            vginfo->vgname && !is_orphan_vg(vginfo->vgname)) {
-               if ((vg = _vg_read(cmd, vginfo->vgname, vgid,
+               if ((vg = _vg_read(cmd, NULL, vgid,
                                   &consistent, precommitted)) &&
                    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
                        if (!consistent) {
This page took 0.0445 seconds and 5 git commands to generate.