]> sourceware.org Git - lvm2.git/commitdiff
Fix up cache for PVs without mdas after consistent VG metadata is processed.
authorAlasdair Kergon <agk@redhat.com>
Fri, 27 Jun 2008 15:18:31 +0000 (15:18 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 27 Jun 2008 15:18:31 +0000 (15:18 +0000)
WHATS_NEW
lib/cache/lvmcache.c
lib/metadata/metadata.c

index b93ef0d4fd57357bfb18b3e9b8668461fa655bb1..7c9ad933f0686afdd9b53b6f31967eb0bbdcff14 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.39 -
 ================================
+  Fix up cache for PVs without mdas after consistent VG metadata is processed.
   Update validation of safe mirror log type conversions in lvconvert.
   Fix lvconvert to disallow snapshot and mirror combinations.
   Fix reporting of LV fields alongside unallocated PV segments.
index a25ccde41c2a4495b5bbd925e662e3871f945e45..139425ff771e32841ed5c4145e51c267af23cd7c 100644 (file)
@@ -845,6 +845,7 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
 {
        struct lvmcache_vginfo *vginfo, *primary_vginfo, *orphan_vginfo;
        struct lvmcache_info *info2, *info3;
+       char mdabuf[32];
        // struct lvmcache_vginfo  *old_vginfo, *next;
 
        if (!vgname || (info && info->vginfo && !strcmp(info->vginfo->vgname, vgname)))
@@ -914,11 +915,16 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
                                orphan_vginfo = vginfo_from_vgname(primary_vginfo->fmt->orphan_vg_name, NULL);
                                _drop_vginfo(info2, primary_vginfo);    
                                _vginfo_attach_info(orphan_vginfo, info2);
-                               log_debug("lvmcache: %s: now in VG %s%s%s%s",
+                               if (info2->mdas.n)
+                                       sprintf(mdabuf, " with %u mdas",
+                                               list_size(&info2->mdas));
+                               else
+                                       mdabuf[0] = '\0';
+                               log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
                                          dev_name(info2->dev),
                                          vgname, orphan_vginfo->vgid[0] ? " (" : "",
                                          orphan_vginfo->vgid[0] ? orphan_vginfo->vgid : "",
-                                         orphan_vginfo->vgid[0] ? ")" : "");
+                                         orphan_vginfo->vgid[0] ? ")" : "", mdabuf);
                }
 
                if (!_insert_vginfo(vginfo, vgid, vgstatus, creation_host,
@@ -947,13 +953,17 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info,
        /* FIXME Check consistency of list! */
        vginfo->fmt = fmt;
 
-       if (info)
-               log_debug("lvmcache: %s: now in VG %s%s%s%s",
+       if (info) {
+               if (info->mdas.n)
+                       sprintf(mdabuf, " with %u mdas", list_size(&info->mdas));
+               else
+                       mdabuf[0] = '\0';
+               log_debug("lvmcache: %s: now in VG %s%s%s%s%s",
                          dev_name(info->dev),
                          vgname, vginfo->vgid[0] ? " (" : "",
                          vginfo->vgid[0] ? vginfo->vgid : "",
-                         vginfo->vgid[0] ? ")" : "");
-       else
+                         vginfo->vgid[0] ? ")" : "", mdabuf);
+       else
                log_debug("lvmcache: initialised VG %s", vgname);
 
        return 1;
index a82242417fea91070f450dbf09e1883e70e70266..6a1b250d5e7125ef4be239e382fdb94513a0f616 100644 (file)
@@ -1488,8 +1488,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
        const struct format_type *fmt;
        struct volume_group *vg, *correct_vg = NULL;
        struct metadata_area *mda;
+       struct lvmcache_info *info;
        int inconsistent = 0;
        int inconsistent_vgid = 0;
+       int inconsistent_pvs = 0;
        unsigned use_precommitted = precommitted;
        struct list *pvids;
        struct pv_list *pvl, *pvl2;
@@ -1564,6 +1566,44 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
 
        /* Ensure every PV in the VG was in the cache */
        if (correct_vg) {
+               /*
+                * If the VG has PVs without mdas, they may still be
+                * orphans in the cache: update the cache state here.
+                */
+               if (!inconsistent &&
+                   list_size(&correct_vg->pvs) > list_size(pvids)) {
+                       list_iterate_items(pvl, &correct_vg->pvs) {
+                               if (!pvl->pv->dev) {
+                                       inconsistent_pvs = 1;
+                                       break;
+                               }
+
+                               if (str_list_match_item(pvids, pvl->pv->dev->pvid))
+                                       continue;
+
+                               /*
+                                * PV not marked as belonging to this VG in cache.
+                                * Check it's an orphan without metadata area.
+                                */
+                               if (!(info = info_from_pvid(pvl->pv->dev->pvid, 1)) ||
+                                  !info->vginfo || !is_orphan_vg(info->vginfo->vgname) ||
+                                  list_size(&info->mdas)) {
+                                       inconsistent_pvs = 1;
+                                       break;
+                               }
+                       }
+
+                       /* If the check passed, let's update VG and recalculate pvids */
+                       if (!inconsistent_pvs) {
+                               log_debug("Updating cache for PVs without mdas "
+                                         "in VG %s.", vgname);
+                               lvmcache_update_vg(correct_vg, use_precommitted);
+
+                               if (!(pvids = lvmcache_get_pvids(cmd, vgname, vgid)))
+                                       return_NULL;
+                       }
+               }
+
                if (list_size(&correct_vg->pvs) != list_size(pvids)) {
                        log_debug("Cached VG %s had incorrect PV list",
                                  vgname);
This page took 0.04526 seconds and 5 git commands to generate.