]> sourceware.org Git - lvm2.git/commitdiff
Add mirror_seg pointer to lv_segment struct. (incomplete & untested)
authorAlasdair Kergon <agk@redhat.com>
Thu, 27 Oct 2005 19:58:22 +0000 (19:58 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 27 Oct 2005 19:58:22 +0000 (19:58 +0000)
WHATS_NEW
lib/activate/dev_manager.c
lib/metadata/lv_manip.c
lib/metadata/merge.c
lib/metadata/metadata.h
lib/metadata/mirror.c

index 51cd7970e6eebd9df50f10d9cc8923689938ccd5..ec79ede851c0e1e162569ba33dbf8ed6a3c29b18 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.00 - 
 ===================================
+  Add mirror_seg pointer to lv_segment struct.
   Only keep a device open if it's known to belong to a locked VG.
   Fix lvdisplay to show all mirror destinations.
   Replacement suspend code using libdevmapper dependency tree.
index a03b941d25e57a5c4916e11d0bd91a9e3e57db7e..a41c18cc8c69285b16cc079a4504485b89ae9f01 100644 (file)
@@ -2164,6 +2164,7 @@ static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
 
 static int _action_activate(struct dev_manager *dm, struct logical_volume *lv)
 {
+       // Replace with deptree code for lv + known deps only.
        if (!_scan_existing_devices(dm)) {
                stack;
                return 0;
index c7f9c807f395ac14a743a7ae7e12cae2654a8885..5f16ef2ec725c727c670210eff85f0d70180eecd 100644 (file)
@@ -97,10 +97,13 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
        seg->region_size = region_size;
        seg->extents_copied = extents_copied;
        seg->log_lv = log_lv;
+       seg->mirror_seg = NULL;
        list_init(&seg->tags);
 
-       if (log_lv)
+       if (log_lv) {
                log_lv->status |= MIRROR_LOG;
+               find_seg_by_le(log_lv, 0)->mirror_seg = seg;
+       }
 
        return seg;
 }
@@ -485,6 +488,9 @@ 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) */
+
        if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv,
                                     lv->le_count,
                                     aa[0].len * area_multiple,
@@ -1059,8 +1065,10 @@ int lv_add_mirror_segment(struct alloc_handle *ah,
                return 0;
        }
 
-       for (m = 0; m < mirrors; m++)
+       for (m = 0; m < mirrors; m++) {
                set_lv_segment_area_lv(seg, m, sub_lvs[m], 0, MIRROR_IMAGE);
+               find_seg_by_le(sub_lvs[m], 0)->mirror_seg = seg;
+       }
 
        list_add(&lv->segments, &seg->list);
        lv->le_count += ah->total_area_len;
index 0e0c6d54445540f817f34ad50057ecb41ffa05d2..a456a1a3fbdc768f6cf64293dc74ce0cf8fcaf4e 100644 (file)
@@ -85,6 +85,40 @@ int check_lv_segments(struct logical_volume *lv)
                        r = 0;
                }
 
+               if (seg->log_lv) {
+                       if (!seg_is_mirrored(seg)) {
+                               log_error("LV %s: segment %u has log LV but "
+                                         "is not mirrored",
+                                         lv->name, seg_count);
+                               r = 0;
+                       }
+
+                       if (!(seg->log_lv->status & MIRROR_LOG)) {
+                               log_error("LV %s: segment %u log LV %s is not "
+                                         "a mirror log",
+                                          lv->name, seg_count, seg->log_lv->name);
+                               r = 0;
+                       }
+
+                       if (!find_seg_by_le(seg->log_lv, 0) ||
+                           find_seg_by_le(seg->log_lv, 0)->mirror_seg != seg) {
+                               log_error("LV %s: segment %u log LV does not "
+                                         "point back to mirror segment",
+                                          lv->name, seg_count);
+                               r = 0;
+                       }
+               }
+
+               if (seg->status & MIRROR_IMAGE) {
+                       if (!seg->mirror_seg ||
+                           !seg_is_mirrored(seg->mirror_seg)) {
+                               log_error("LV %s: segment %u mirror image "
+                                         "is not mirrored",
+                                         lv->name, seg_count);
+                               r = 0;
+                       }
+               }
+
                for (s = 0; s < seg->area_count; s++) {
                        if (seg_type(seg, s) == AREA_UNASSIGNED) {
                                log_error("LV %s: segment %u has unassigned "
@@ -109,6 +143,18 @@ int check_lv_segments(struct logical_volume *lv)
                                                  lv->name, seg_count, s);
                                        r = 0;
                                }
+
+                               if (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
+                                                       != seg)) {
+                                       log_error("LV %s: segment %u mirror "
+                                                 "image %u missing mirror ptr",
+                                                 lv->name, seg_count, s);
+                                       r = 0;
+                               }
+
 /* FIXME I don't think this ever holds?
                                if (seg_le(seg, s) != le) {
                                        log_error("LV %s: segment %u has "
index 7eaa231ad501ba1cb1013d6d3d74cd1915b2181c..1425136c1a7427efcc625b1358a186df8c31f6d5 100644 (file)
@@ -251,6 +251,7 @@ struct lv_segment {
        uint32_t region_size;   /* For mirrors - in sectors */
        uint32_t extents_copied;
        struct logical_volume *log_lv;
+       struct lv_segment *mirror_seg;
 
        struct list tags;
 
@@ -559,6 +560,10 @@ int create_mirror_layers(struct alloc_handle *ah,
                         struct logical_volume *log_lv);
 int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors);
 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 insert_pvmove_mirrors(struct cmd_context *cmd,
                          struct logical_volume *lv_mirr,
index 4952393e434cdeeb03e840d1809edf11a291c846..bc292f652656b5fa15333259b9da419686d32507 100644 (file)
 #include "lv_alloc.h"
 #include "lvm-string.h"
 
+struct lv_segment *find_mirror_seg(struct lv_segment *seg)
+{
+       return seg->mirror_seg;
+}
+
 /*
  * Ensure region size is compatible with volume size.
  */
@@ -149,8 +154,8 @@ int create_mirror_layers(struct alloc_handle *ah,
        for (m = 0; m < num_mirrors; m++) {
                if (!(img_lvs[m] = lv_create_empty(lv->vg->fid, img_name,
                                             NULL, LVM_READ | LVM_WRITE,
-                                            ALLOC_INHERIT, 0, lv->vg))) {\
-                       log_error("Aborting. Failed to create submirror LV. "
+                                            ALLOC_INHERIT, 0, lv->vg))) {
+                       log_error("Aborting. Failed to create mirror image LV. "
                                  "Remove new LV and retry.");
                        return 0;
                }
@@ -159,7 +164,7 @@ int create_mirror_layers(struct alloc_handle *ah,
                                    get_segtype_from_string(lv->vg->cmd,
                                                            "striped"),
                                    0, NULL, 0, 0, 0, NULL)) {
-                       log_error("Aborting. Failed to add submirror segment "
+                       log_error("Aborting. Failed to add mirror image segment "
                                  "to %s. Remove new LV and retry.",
                                  img_lvs[m]->name);
                        return 0;
This page took 0.050621 seconds and 5 git commands to generate.