]> sourceware.org Git - lvm2.git/commitdiff
add a warning message when updating old metadata
authorDavid Teigland <teigland@redhat.com>
Wed, 6 Feb 2019 19:51:54 +0000 (13:51 -0600)
committerDavid Teigland <teigland@redhat.com>
Fri, 7 Jun 2019 20:54:04 +0000 (15:54 -0500)
in an mda that had previously not been updated

lib/metadata/metadata.c

index 5eabfa68f4b0f27f8493cb56edac5ba888024f1c..2d3ff1c28fbf18e2a7cc2b5c1cbc4654e74d79fc 100644 (file)
@@ -2947,6 +2947,7 @@ int vg_write(struct volume_group *vg)
        struct pv_list *pvl, *pvl_safe, *new_pvl;
        struct metadata_area *mda;
        struct lv_list *lvl;
+       struct device *mda_dev;
        int revert = 0, wrote = 0;
 
        if (vg_is_shared(vg)) {
@@ -3040,14 +3041,34 @@ int vg_write(struct volume_group *vg)
 
        /* Write to each copy of the metadata area */
        dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
+               mda_dev = mda_get_device(mda);
+
                if (mda->status & MDA_FAILED)
                        continue;
+
+               /*
+                * When the scan and vg_read find old metadata in an mda, they
+                * leave the info struct in lvmcache, and leave the mda in
+                * info->mdas.  That means we use the mda here to write new
+                * metadata into.  This means that a command writing a VG will
+                * automatically update old metadata to the latest.
+                *
+                * This can also happen if the metadata was ignored on this
+                * dev, and then it's later changed to not ignored, and
+                * we see the old metadata.
+                */
+               if (lvmcache_has_old_metadata(vg->cmd, vg->name, (const char *)&vg->id, mda_dev)) {
+                       log_warn("WARNING: updating old metadata to %u on %s for VG %s.",
+                                vg->seqno, dev_name(mda_dev), vg->name);
+               }
+
                if (!mda->ops->vg_write) {
                        log_error("Format does not support writing volume"
                                  "group metadata areas");
                        revert = 1;
                        break;
                }
+
                if (!mda->ops->vg_write(vg->fid, vg, mda)) {
                        if (vg->cmd->handles_missing_pvs) {
                                log_warn("WARNING: Failed to write an MDA of VG %s.", vg->name);
This page took 0.040483 seconds and 5 git commands to generate.