]> sourceware.org Git - lvm2.git/commitdiff
Fix new mirror_seg pointer.
authorAlasdair Kergon <agk@redhat.com>
Thu, 27 Oct 2005 21:51:28 +0000 (21:51 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 27 Oct 2005 21:51:28 +0000 (21:51 +0000)
lib/cache/lvmcache.c
lib/format_text/import_vsn1.c
lib/metadata/lv_manip.c
lib/metadata/merge.c
lib/metadata/metadata.c
lib/metadata/metadata.h
lib/metadata/mirror.c

index 654ac25610e2e636956598d65c0bfd59cd1b3790..4ac298be32578422f3e1e7fdd30861159590cf47 100644 (file)
@@ -512,6 +512,10 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
                                                 "using dm %s", pvid,
                                                 dev_name(existing->dev),
                                                 dev_name(dev));
+                       /* FIXME If both dm, check dependencies */
+                       //else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
+                                //dm_is_dm_major(MAJOR(dev->dev)))
+                                //
                        else
                                log_error("Found duplicate PV %s: using %s not "
                                          "%s", pvid, dev_name(dev),
index a70dfe29dcf72593272625f141bdbbd3bfcd2337..14d9abf3f440d0ff87c8b7dfccca9abff3dd92f2 100644 (file)
@@ -428,7 +428,7 @@ static int _read_segments(struct dm_pool *mem, struct volume_group *vg,
        /*
         * Check there are no gaps or overlaps in the lv.
         */
-       if (!check_lv_segments(lv)) {
+       if (!check_lv_segments(lv, 0)) {
                stack;
                return 0;
        }
@@ -757,6 +757,12 @@ static struct volume_group *_read_vg(struct format_instance *fid,
                goto bad;
        }
 
+       if (!fixup_imported_mirrors(vg)) {
+               log_error("Failed to fixup mirror pointers after import for "
+                         "volume group %s.", vg->name);
+               goto bad;
+       }
+
        dm_hash_destroy(pv_hash);
 
        if (vg->status & PARTIAL_VG) {
index 5f16ef2ec725c727c670210eff85f0d70180eecd..d96c77475267d0899650abcca08ac3c8145ee0eb 100644 (file)
@@ -488,13 +488,11 @@ static int _setup_alloced_segment(struct logical_volume *lv, uint32_t status,
 
        area_multiple = segtype_is_striped(segtype) ? area_count : 1;
 
-       /* FIXME Shouldn't log_lv always be NULL here? */
-       /* (As we set up log segments elsewhere) */
-
+       /* log_lv gets set up elsehere */
        if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv,
                                     lv->le_count,
                                     aa[0].len * area_multiple,
-                                    status, stripe_size, log_lv,
+                                    status, stripe_size, NULL,
                                     area_count + extra_areas,
                                     aa[0].len, 0u, region_size, 0u))) {
                log_error("Couldn't allocate new LV segment.");
index a456a1a3fbdc768f6cf64293dc74ce0cf8fcaf4e..f861c52889e930a4be81d541b7cda2c4a57806ac 100644 (file)
@@ -58,9 +58,9 @@ int lv_merge_segments(struct logical_volume *lv)
 /*
  * Verify that an LV's segments are consecutive, complete and don't overlap.
  */
-int check_lv_segments(struct logical_volume *lv)
+int check_lv_segments(struct logical_volume *lv, int complete_vg)
 {
-       struct lv_segment *seg;
+       struct lv_segment *seg, *seg2;
        uint32_t le = 0;
        unsigned seg_count = 0;
        int r = 1;
@@ -85,7 +85,7 @@ int check_lv_segments(struct logical_volume *lv)
                        r = 0;
                }
 
-               if (seg->log_lv) {
+               if (complete_vg && seg->log_lv) {
                        if (!seg_is_mirrored(seg)) {
                                log_error("LV %s: segment %u has log LV but "
                                          "is not mirrored",
@@ -100,8 +100,8 @@ int check_lv_segments(struct logical_volume *lv)
                                r = 0;
                        }
 
-                       if (!find_seg_by_le(seg->log_lv, 0) ||
-                           find_seg_by_le(seg->log_lv, 0)->mirror_seg != seg) {
+                       if (!(seg2 = find_seg_by_le(seg->log_lv, 0)) ||
+                           seg2->mirror_seg != seg) {
                                log_error("LV %s: segment %u log LV does not "
                                          "point back to mirror segment",
                                           lv->name, seg_count);
@@ -109,7 +109,7 @@ int check_lv_segments(struct logical_volume *lv)
                        }
                }
 
-               if (seg->status & MIRROR_IMAGE) {
+               if (complete_vg && seg->status & MIRROR_IMAGE) {
                        if (!seg->mirror_seg ||
                            !seg_is_mirrored(seg->mirror_seg)) {
                                log_error("LV %s: segment %u mirror image "
@@ -144,7 +144,7 @@ int check_lv_segments(struct logical_volume *lv)
                                        r = 0;
                                }
 
-                               if (seg_lv(seg, s) &&
+                               if (complete_vg && seg_lv(seg, s) &&
                                    (seg_lv(seg, s)->status & MIRROR_IMAGE) &&
                                    (find_seg_by_le(seg_lv(seg, s),
                                                    seg_le(seg, s))->mirror_seg
index d6807194572232a9c3bd26edc5994ad2db4d5acf..c44d56ff72667961ef630e2f6e3d96e4f90bb627 100644 (file)
@@ -715,7 +715,7 @@ int vg_validate(struct volume_group *vg)
        }
 
        list_iterate_items(lvl, &vg->lvs) {
-               if (!check_lv_segments(lvl->lv)) {
+               if (!check_lv_segments(lvl->lv, 1)) {
                        log_error("Internal error: LV segments corrupted in %s.",
                                  lvl->lv->name);
                        return 0;
@@ -1076,7 +1076,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
        }
 
        list_iterate_items(lvl, &vg->lvs) {
-               if (!check_lv_segments(lvl->lv)) {
+               if (!check_lv_segments(lvl->lv, 1)) {
                        log_error("Internal error: LV segments corrupted in %s.",
                                  lvl->lv->name);
                        return NULL;
index 1425136c1a7427efcc625b1358a186df8c31f6d5..233729bce7603637f50e17656ddc1276b3c53cd6 100644 (file)
@@ -512,8 +512,9 @@ const char *strip_dir(const char *vg_name, const char *dir);
 
 /*
  * Checks that an lv has no gaps or overlapping segments.
+ * Set complete_vg to perform additional VG level checks.
  */
-int check_lv_segments(struct logical_volume *lv);
+int check_lv_segments(struct logical_volume *lv, int complete_vg);
 
 /*
  * Sometimes (eg, after an lvextend), it is possible to merge two
@@ -564,6 +565,7 @@ int remove_all_mirror_images(struct logical_volume *lv);
  * Given mirror image or mirror log segment, find corresponding mirror segment 
  */
 struct lv_segment *find_mirror_seg(struct lv_segment *seg);
+int fixup_imported_mirrors(struct volume_group *vg);
 
 int insert_pvmove_mirrors(struct cmd_context *cmd,
                          struct logical_volume *lv_mirr,
index bc292f652656b5fa15333259b9da419686d32507..f48b808f4853a715ccbc4bd64befc1d83db2fc19 100644 (file)
@@ -551,3 +551,29 @@ float copy_percent(struct logical_volume *lv_mirr)
 
        return denominator ? (float) numerator *100 / denominator : 100.0;
 }
+
+/*
+ * Fixup mirror pointers after single-pass segment import
+ */
+int fixup_imported_mirrors(struct volume_group *vg)
+{
+       struct lv_list *lvl;
+       struct lv_segment *seg;
+       uint32_t s;
+
+       list_iterate_items(lvl, &vg->lvs) {
+               list_iterate_items(seg, &lvl->lv->segments) {
+                       if (seg->segtype !=
+                           get_segtype_from_string(vg->cmd, "mirror"))
+                               continue;
+
+                       if (seg->log_lv)
+                               find_seg_by_le(seg->log_lv, 0)->mirror_seg = seg;
+                       for (s = 0; s < seg->area_count; s++)
+                               if (seg_type(seg, s) == AREA_LV)
+                                       find_seg_by_le(seg_lv(seg, s), 0)->
+                                           mirror_seg = seg;
+               }
+       }
+}
+
This page took 0.199273 seconds and 5 git commands to generate.