public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/metadata/metadata.c tools/vgmerge.c t ...
@ 2010-12-14 17:51 mornfall
  0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2010-12-14 17:51 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-12-14 17:51:11

Modified files:
	lib/metadata   : metadata.c 
	tools          : vgmerge.c vgsplit.c 

Log message:
	Add further consistency checking to vg_validate, ensuring that all segment
	areas point to LVs or PVs that are listed in the respective VG.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.417&r2=1.418
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104

--- LVM2/lib/metadata/metadata.c	2010/12/14 17:07:35	1.417
+++ LVM2/lib/metadata/metadata.c	2010/12/14 17:51:09	1.418
@@ -2153,6 +2153,61 @@
 	}
 }
 
+/*
+ * Check that an LV and all its PV references are correctly listed in vg->lvs
+ * and vg->pvs, respectively. This only looks at a single LV, but *not* at the
+ * LVs it is using. To do the latter, you should use _lv_postorder with this
+ * function. C.f. vg_validate.
+ */
+static int _lv_validate_references_single(struct logical_volume *lv, void *data)
+{
+	struct volume_group *vg = lv->vg;
+	struct lv_segment *lvseg;
+	struct pv_list *pvl;
+	struct lv_list *lvl;
+	int s;
+	int r = 1;
+	int ok = 0;
+
+	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (lvl->lv == lv) {
+			ok = 1;
+			break;
+		}
+	}
+
+	if (!ok) {
+		log_error(INTERNAL_ERROR
+			  "Referenced LV %s not listed in VG %s.",
+			  lv->name, vg->name);
+		r = 0;
+	}
+
+	dm_list_iterate_items(lvseg, &lv->segments) {
+		for (s = 0; s < lvseg->area_count; ++s) {
+			if (seg_type(lvseg, s) == AREA_PV) {
+				ok = 0;
+				/* look up the reference in vg->pvs */
+				dm_list_iterate_items(pvl, &vg->pvs) {
+					if (pvl->pv == seg_pv(lvseg, s)) {
+						ok = 1;
+						break;
+					}
+				}
+
+				if (!ok) {
+					log_error(INTERNAL_ERROR
+						  "Referenced PV %s not listed in VG %s.",
+						  pv_dev_name(seg_pv(lvseg, s)), vg->name);
+					r = 0;
+				}
+			}
+		}
+	}
+
+	return r;
+}
+
 int vg_validate(struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
@@ -2320,6 +2375,11 @@
 	}
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
+		if (!_lv_postorder(lvl->lv, _lv_validate_references_single, NULL))
+			r = 0;
+	}
+
+	dm_list_iterate_items(lvl, &vg->lvs) {
 		if (!(lvl->lv->status & PVMOVE))
 			continue;
 		dm_list_iterate_items(seg, &lvl->lv->segments) {
--- LVM2/tools/vgmerge.c	2010/12/08 20:50:51	1.70
+++ LVM2/tools/vgmerge.c	2010/12/14 17:51:10	1.71
@@ -114,6 +114,10 @@
 		}
 	}
 
+	dm_list_iterate_items(lvl1, &vg_from->lvs) {
+		lvl1->lv->vg = vg_to;
+	}
+
 	while (!dm_list_empty(&vg_from->lvs)) {
 		struct dm_list *lvh = vg_from->lvs.n;
 
--- LVM2/tools/vgsplit.c	2010/12/08 20:50:51	1.103
+++ LVM2/tools/vgsplit.c	2010/12/14 17:51:10	1.104
@@ -34,6 +34,7 @@
 	struct logical_volume *lv = dm_list_item(lvh, struct lv_list)->lv;
 
 	dm_list_move(&vg_to->lvs, lvh);
+	lv->vg = vg_to;
 
 	if (lv_is_active(lv)) {
 		log_error("Logical volume \"%s\" must be inactive", lv->name);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2 lib/metadata/metadata.c tools/vgmerge.c t ...
@ 2008-03-26 17:26 wysochanski
  0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2008-03-26 17:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-03-26 17:26:32

Modified files:
	lib/metadata   : metadata.c 
	tools          : vgmerge.c vgsplit.c 

Log message:
	Use list_move() in applicable places.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52

--- LVM2/lib/metadata/metadata.c	2008/03/26 16:48:10	1.161
+++ LVM2/lib/metadata/metadata.c	2008/03/26 17:26:32	1.162
@@ -708,10 +708,8 @@
 			continue;
 		}
 
-		if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda)) {
-			list_del(&mda->list);
-			list_add(mdas_to, &mda->list);
-		}
+		if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda))
+			list_move(&mda->list, mdas_to);
 	}
 
 	if (list_empty(mdas_from) || list_empty(mdas_to))
--- LVM2/tools/vgmerge.c	2008/01/30 14:00:02	1.45
+++ LVM2/tools/vgmerge.c	2008/03/26 17:26:32	1.46
@@ -54,8 +54,7 @@
 		struct list *pvh = vg_from->pvs.n;
 		struct physical_volume *pv;
 
-		list_del(pvh);
-		list_add(&vg_to->pvs, pvh);
+		list_move(pvh, &vg_to->pvs);
 
 		pv = list_item(pvh, struct pv_list)->pv;
 		pv->vg_name = dm_pool_strdup(cmd->mem, vg_to->name);
@@ -90,15 +89,13 @@
 	while (!list_empty(&vg_from->lvs)) {
 		struct list *lvh = vg_from->lvs.n;
 
-		list_del(lvh);
-		list_add(&vg_to->lvs, lvh);
+		list_move(lvh, &vg_to->lvs);
 	}
 
 	while (!list_empty(&vg_from->fid->metadata_areas)) {
 		struct list *mdah = vg_from->fid->metadata_areas.n;
 
-		list_del(mdah);
-		list_add(&vg_to->fid->metadata_areas, mdah);
+		list_move(mdah, &vg_to->fid->metadata_areas);
 	}
 
 	vg_to->lv_count += vg_from->lv_count;
--- LVM2/tools/vgsplit.c	2008/02/29 00:13:48	1.51
+++ LVM2/tools/vgsplit.c	2008/03/26 17:26:32	1.52
@@ -20,8 +20,7 @@
 {
 	struct physical_volume *pv;
 
-	list_del(&pvl->list);
-	list_add(&vg_to->pvs, &pvl->list);
+	list_move(&pvl->list, &vg_to->pvs);
 
 	vg_from->pv_count--;
 	vg_to->pv_count++;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-14 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-14 17:51 LVM2 lib/metadata/metadata.c tools/vgmerge.c t mornfall
  -- strict thread matches above, loose matches on Subject: below --
2008-03-26 17:26 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).