]> sourceware.org Git - lvm2.git/commitdiff
more metadataignore message/code cleanup
authorAlasdair Kergon <agk@redhat.com>
Wed, 30 Jun 2010 17:13:05 +0000 (17:13 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 30 Jun 2010 17:13:05 +0000 (17:13 +0000)
lib/format_text/format-text.c
lib/format_text/layout.h
lib/metadata/metadata.c

index 86089723b6cdca61eb8e22e7c907f4fcf8f21ec6..c6594af485650c5b256424733c196ae80f3651b4 100644 (file)
@@ -68,9 +68,9 @@ int rlocn_is_ignored(const struct raw_locn *rlocn)
        return (rlocn->flags & RAW_LOCN_IGNORED ? 1 : 0);
 }
 
-void rlocn_set_ignored(struct raw_locn *rlocn, int value)
+void rlocn_set_ignored(struct raw_locn *rlocn, unsigned mda_ignored)
 {
-       if (value)
+       if (mda_ignored)
                rlocn->flags |= RAW_LOCN_IGNORED;
        else
                rlocn->flags &= ~RAW_LOCN_IGNORED;
index 5c90c151fa00b962bb494dccf1e780291a2d8e9a..a3141e07d108b0b2a5614e0648c8f2936da582aa 100644 (file)
@@ -62,7 +62,7 @@ struct raw_locn {
 } __attribute__ ((packed));
 
 int rlocn_is_ignored(const struct raw_locn *rlocn);
-void rlocn_set_ignored(struct raw_locn *rlocn, int value);
+void rlocn_set_ignored(struct raw_locn *rlocn, unsigned mda_ignored);
 
 /* On disk */
 /* Structure size limited to one sector */
index 44ad83e1d7b6a4222e85e845a52456de9b737c18..0b7063d215fea58b36a7df500078ed2b25ec17d4 100644 (file)
@@ -2615,13 +2615,12 @@ static int _vg_commit_mdas(struct volume_group *vg)
 
        /* Rearrange the metadata_areas_in_use so ignored mdas come first. */
        dm_list_init(&ignored);
-       dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_in_use) {
+       dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_in_use)
                if (mda_is_ignored(mda))
                        dm_list_move(&ignored, &mda->list);
-       }
-       dm_list_iterate_items_safe(mda, tmda, &ignored) {
+
+       dm_list_iterate_items_safe(mda, tmda, &ignored)
                dm_list_move(&vg->fid->metadata_areas_in_use, &mda->list);
-       }
 
        /* Commit to each copy of the metadata area */
        dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
@@ -4067,12 +4066,8 @@ uint32_t pv_pe_alloc_count(const struct physical_volume *pv)
 
 void fid_add_mda(struct format_instance *fid, struct metadata_area *mda)
 {
-       if (mda_is_ignored(mda))
-               dm_list_add(&fid->metadata_areas_ignored,
-                           &mda->list);
-       else
-               dm_list_add(&fid->metadata_areas_in_use,
-                           &mda->list);
+       dm_list_add(mda_is_ignored(mda) ? &fid->metadata_areas_ignored :
+                                         &fid->metadata_areas_in_use, &mda->list);
 }
 
 int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas)
@@ -4149,20 +4144,20 @@ unsigned mda_is_ignored(struct metadata_area *mda)
        return (mda->flags & MDA_IGNORED);
 }
 
-void mda_set_ignored(struct metadata_area *mda, unsigned ignored)
+void mda_set_ignored(struct metadata_area *mda, unsigned mda_ignored)
 {
        void *locn = mda->metadata_locn;
-       unsigned old_ignored = mda_is_ignored(mda);
+       unsigned old_mda_ignored = mda_is_ignored(mda);
 
-       if (ignored && !old_ignored)
+       if (mda_ignored && !old_mda_ignored)
                mda->flags |= MDA_IGNORED;
-       else if (!ignored && old_ignored)
+       else if (!mda_ignored && old_mda_ignored)
                mda->flags &= ~MDA_IGNORED;
        else
                return; /* No change */
 
        log_debug("%s ignored flag for mda %s at offset %" PRIu64 ".", 
-                 ignored ? "Setting" : "Clearing",
+                 mda_ignored ? "Setting" : "Clearing",
                  mda->ops->mda_metadata_locn_name ? mda->ops->mda_metadata_locn_name(locn) : "",
                  mda->ops->mda_metadata_locn_offset ? mda->ops->mda_metadata_locn_offset(locn) : UINT64_C(0));
 }
@@ -4191,20 +4186,18 @@ uint32_t pv_mda_used_count(const struct physical_volume *pv)
        return used_count;
 }
 
-unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored)
+unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned mda_ignored)
 {
        struct lvmcache_info *info;
        struct metadata_area *mda, *vg_mda, *tmda;
        struct dm_list *vg_mdas_in_use, *vg_mdas_ignored;
 
-       info = info_from_pvid((const char *)&pv->id.uuid, 0);
-       if (!info)
+       if (!(info = info_from_pvid((const char *)&pv->id.uuid, 0)))
                return_0;
 
        if (is_orphan(pv)) {
-               dm_list_iterate_items(mda, &info->mdas) {
-                       mda_set_ignored(mda, ignored);
-               }
+               dm_list_iterate_items(mda, &info->mdas)
+                       mda_set_ignored(mda, mda_ignored);
                return 1;
        }
 
@@ -4212,7 +4205,8 @@ unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored)
         * Do not allow disabling of the the last PV in a VG.
         */
        if (pv_mda_used_count(pv) == vg_mda_used_count(pv->vg)) {
-               log_error("Cannot disable all metadata areas in Volume Group.");
+               log_error("Cannot disable all metadata areas in volume group %s.",
+                         pv->vg->name);
                return 0;
        }
 
@@ -4229,24 +4223,24 @@ unsigned pv_mda_set_ignored(const struct physical_volume *pv, unsigned ignored)
         */
        vg_mdas_in_use = &pv->vg->fid->metadata_areas_in_use;
        vg_mdas_ignored = &pv->vg->fid->metadata_areas_ignored;
+
        dm_list_iterate_items(mda, &info->mdas) {
-               if (mda_is_ignored(mda) && !ignored) {
+               if (mda_is_ignored(mda) && !mda_ignored)
                        /* Changing an ignored mda to one in_use requires moving it */
-                       dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_ignored) {
+                       dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_ignored)
                                if (mda_locns_match(mda, vg_mda)) {
-                                       mda_set_ignored(vg_mda, ignored);
+                                       mda_set_ignored(vg_mda, mda_ignored);
                                        dm_list_move(vg_mdas_in_use, &vg_mda->list);
                                }
-                       }
-               }
-               dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_in_use) {
-                       if (mda_locns_match(mda, vg_mda)) {
-                               mda_set_ignored(vg_mda, ignored);
-                               /* don't move mda - needs written to disk */
-                       }
-               }
-               mda_set_ignored(mda, ignored);
+
+               dm_list_iterate_items_safe(vg_mda, tmda, vg_mdas_in_use)
+                       if (mda_locns_match(mda, vg_mda))
+                               /* Don't move mda: needs writing to disk. */
+                               mda_set_ignored(vg_mda, mda_ignored);
+
+               mda_set_ignored(mda, mda_ignored);
        }
+
        return 1;
 }
 
@@ -4267,31 +4261,30 @@ int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore)
 {
        const char *pv_name = pv_dev_name(pv);
 
-       if (mda_ignore && (pv_mda_used_count(pv) == 0)) {
-               log_error("Physical volume \"%s\" metadata already "
-                         "ignored", pv_name);
+       if (mda_ignore && !pv_mda_used_count(pv)) {
+               log_error("Metadata areas on physical volume \"%s\" already "
+                         "ignored.", pv_name);
                return 0;
        }
+
        if (!mda_ignore && (pv_mda_used_count(pv) == pv_mda_count(pv))) {
-               log_error("Physical volume \"%s\" metadata already "
-                         "not ignored", pv_name);
+               log_error("Metadata areas on physical volume \"%s\" already "
+                         "marked as in-use.", pv_name);
                return 0;
        }
+
        if (!pv_mda_count(pv)) {
                log_error("Physical volume \"%s\" has no metadata "
-                         "areas ", pv_name);
-               return 0;
-       }
-       if (mda_ignore) {
-               log_verbose("Setting physical volume \"%s\" "
-                           "metadata ignored", pv_name);
-       } else {
-               log_verbose("Setting physical volume \"%s\" "
-                           "metadata not ignored", pv_name);
-       }
-       if (!pv_mda_set_ignored(pv, mda_ignore)) {
+                         "areas.", pv_name);
                return 0;
        }
+
+       log_verbose("Marking metadata areas on physical volume \"%s\" "
+                   "as %s.", pv_name, mda_ignore ? "ignored" : "in-use");
+
+       if (!pv_mda_set_ignored(pv, mda_ignore))
+               return_0;
+
        /*
         * Update vg_mda_copies based on the mdas in this PV.
         * This is most likely what the user would expect - if they
@@ -4301,9 +4294,9 @@ int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore)
         * This does not guarantee this PV's ignore bits will be
         * preserved in future operations.
         */
-       if (!is_orphan(pv) && vg_mda_copies(pv->vg)) {
+       if (!is_orphan(pv) && vg_mda_copies(pv->vg))
                vg_set_mda_copies(pv->vg, vg_mda_used_count(pv->vg));
-       }
+
        return 1;
 }
 
@@ -4373,14 +4366,13 @@ uint32_t vg_mda_used_count(const struct volume_group *vg)
         * may have changed from ignored to un-ignored and we need to write
         * the state to disk.
         */
-       dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
+       dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use)
               if (!mda_is_ignored(mda))
                       used_count++;
-       }
-       dm_list_iterate_items(mda, &vg->fid->metadata_areas_ignored) {
+
+       dm_list_iterate_items(mda, &vg->fid->metadata_areas_ignored)
               if (!mda_is_ignored(mda))
                       used_count++;
-       }
 
        return used_count;
 }
This page took 0.061854 seconds and 5 git commands to generate.