[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] vg_validate support for pvmove LVs (BZ 662669)



Hi,

I am attaching patch that revs up vg_validate somewhat, to catch some
malformed (internal) pvmoveN LVs. Currently, it checks that the segments
in there are either linear or mirrored with 2 legs. Unfortunately, I
haven't been able to come up with any further restrictions that wouldn't
break the existing tests on some count. It seems that vg_validate is
called on VGs where linear segments exist (although I have been unable
to capture them at vg_commit time), and they are interspersed with
mirrored segments in the same LV. I have already spent a lot of time on
this, so if someone wants to come up with a stricter check, please feel
free to do so.

Anyway, the attached patch does catch the bug triggered by kabi's test
attached to BZ 654447. For the other bug (dangling reference) I will
submit a separate BZ and a separate patch, hopefully tomorrow.

Yours,
   Petr

--- old-vgreduce-removemissing/lib/metadata/metadata.c	2010-12-13 22:19:11.000000000 +0100
+++ new-vgreduce-removemissing/lib/metadata/metadata.c	2010-12-13 22:19:11.000000000 +0100
@@ -2157,6 +2157,7 @@ int vg_validate(struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
 	struct lv_list *lvl, *lvl2;
+	struct lv_segment *seg;
 	char uuid[64] __attribute__((aligned(8)));
 	int r = 1;
 	uint32_t hidden_lv_count = 0, lv_count = 0, lv_visible_count = 0;
@@ -2318,6 +2319,26 @@ int vg_validate(struct volume_group *vg)
 		}
 	}
 
+	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (!(lvl->lv->status & PVMOVE))
+			continue;
+		dm_list_iterate_items(seg, &lvl->lv->segments) {
+			if (seg_is_mirrored(seg)) {
+				if (seg->area_count != 2) {
+					log_error(INTERNAL_ERROR
+						  "Segment %d in %s is not 2-way.",
+						  loop_counter1, lvl->lv->name);
+					r = 0;
+				}
+			} else if (seg->area_count != 1) {
+				log_error(INTERNAL_ERROR
+					  "Segment %d in %s has wrong number of areas: %d.",
+					  loop_counter1, lvl->lv->name, seg->area_count);
+				r = 0;
+			}
+		}
+	}
+
 	if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS) &&
 	    (!vg->max_lv || !vg->max_pv)) {
 		log_error(INTERNAL_ERROR "Volume group %s has limited PV/LV count"

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]