This is the mail archive of the lvm2-cvs@sourceware.org mailing list for the LVM2 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

LVM2 ./WHATS_NEW lib/metadata/metadata.c


CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-08-09 19:33:25

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c 

Log message:
	Add checks for duplicate LV name, lvid and PV id before writing metadata.
	Report all sanity check failures, not just the first.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.415&r2=1.416
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95

--- LVM2/WHATS_NEW	2006/08/08 21:20:00	1.415
+++ LVM2/WHATS_NEW	2006/08/09 19:33:25	1.416
@@ -1,5 +1,7 @@
 Version 2.02.08 - 
 ================================
+  Add checks for duplicate LV name, lvid and PV id before writing metadata.
+  Report all sanity check failures, not just the first.
   Fix missing lockfs on first snapshot creation.
   Add unreliable --trustcache option to reporting commands.
   Fix locking for mimage removal.
--- LVM2/lib/metadata/metadata.c	2006/07/04 19:36:49	1.94
+++ LVM2/lib/metadata/metadata.c	2006/08/09 19:33:25	1.95
@@ -722,23 +722,68 @@
 
 int vg_validate(struct volume_group *vg)
 {
-	struct lv_list *lvl;
+	struct pv_list *pvl, *pvl2;
+	struct lv_list *lvl, *lvl2;
+	char uuid[64];
+	int r = 1;
+
+	list_iterate_items(pvl, &vg->pvs) {
+		list_iterate_items(pvl2, &vg->pvs) {
+			if (pvl == pvl2)
+				break;
+			if (id_equal(&pvl->pv->id,
+				     &pvl2->pv->id)) {
+				if (!id_write_format(&pvl->pv->id, uuid,
+						     sizeof(uuid)))
+					 stack;
+				log_error("Internal error: Duplicate PV id "
+					  "%s detected for %s in %s.",
+					  uuid, dev_name(pvl->pv->dev),
+					  vg->name);
+				r = 0;
+			}
+		}
+	}
 
 	if (!check_pv_segments(vg)) {
 		log_error("Internal error: PV segments corrupted in %s.",
 			  vg->name);
-		return 0;
+		r = 0;
+	}
+
+	list_iterate_items(lvl, &vg->lvs) {
+		list_iterate_items(lvl2, &vg->lvs) {
+			if (lvl == lvl2)
+				break;
+			if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
+				log_error("Internal error: Duplicate LV name "
+					  "%s detected in %s.", lvl->lv->name,
+					  vg->name);
+				r = 0;
+			}
+			if (id_equal(&lvl->lv->lvid.id[1],
+				     &lvl2->lv->lvid.id[1])) {
+				if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
+						     sizeof(uuid)))
+					 stack;
+				log_error("Internal error: Duplicate LV id "
+					  "%s detected for %s and %s in %s.",
+					  uuid, lvl->lv->name, lvl2->lv->name,
+					  vg->name);
+				r = 0;
+			}
+		}
 	}
 
 	list_iterate_items(lvl, &vg->lvs) {
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error("Internal error: LV segments corrupted in %s.",
 				  lvl->lv->name);
-			return 0;
+			r = 0;
 		}
 	}
 
-	return 1;
+	return r;
 }
 
 /*


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]