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

Re: [lvm-devel] [PATCH] (4/6) new vgreduce --removemissing semantics



Hi,

Petr Rockai <prockai redhat com> writes:
> but please bear with me, I will come with a better one in a few minutes.
I am attaching a new version of the patch that solves the issue in a hopefully
better way, and also adds a comment on what is the problem with the original
approach.

Yours,
   Petr.

Wed Sep 10 14:22:15 CEST 2008  me mornfall net
  * Fix compiler errors introduced by the --removemissing --force fix.
Wed Sep 10 14:16:47 CEST 2008  me mornfall net
  * Do not use _consolidate_vg in _make_vg_consistent and explain why.
Wed Sep 10 14:12:52 CEST 2008  me mornfall net
  * Also check for MISSING_PV in _make_vg_consistent.
Wed Sep 10 13:49:58 CEST 2008  me mornfall net
  * Roll back a bad fix for --removemissing --force breakage.
Tue Sep  9 16:42:32 CEST 2008  me mornfall net
  * Un-break vgreduce --removemissing --force.
diff -rN -p -u old-hotspare-everything/tools/vgreduce.c new-hotspare-everything/tools/vgreduce.c
--- old-hotspare-everything/tools/vgreduce.c	2008-09-10 14:40:14.720289087 +0200
+++ new-hotspare-everything/tools/vgreduce.c	2008-09-10 14:40:14.772288014 +0200
@@ -165,7 +165,9 @@ static int _consolidate_vg(struct cmd_co
 
 static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
 {
+	struct list *pvh, *pvht;
 	struct list *lvh, *lvht;
+	struct pv_list *pvl;
 	struct lv_list *lvl, *lvl2, *lvlt;
 	struct logical_volume *lv;
 	struct physical_volume *pv;
@@ -193,7 +195,8 @@ static int _make_vg_consistent(struct cm
 				/* FIXME Also check for segs on deleted LVs (incl pvmove) */
 
 				pv = seg_pv(seg, s);
-				if (!pv || !pv_dev(pv)) {
+				if (!pv || !pv_dev(pv) ||
+				    (pv->status & MISSING_PV)) {
 					if (arg_count(cmd, mirrorsonly_ARG) &&
 					    !(lv->status & MIRROR_IMAGE)) {
 						log_error("Non-mirror-image LV %s found: can't remove.", lv->name);
@@ -214,8 +217,21 @@ static int _make_vg_consistent(struct cm
 		return 0;
 	}
 
-	if (!_consolidate_vg(cmd, vg))
-		return_0;
+	/*
+	 * Remove missing PVs. FIXME: This duplicates _consolidate_vg above,
+	 * but we cannot use that right now, since the LV removal code in this
+	 * function leaves the VG in a "somewhat inconsistent" state and
+	 * _consolidate_vg doesn't like that -- specifically, mirrors are fixed
+	 * up *after* the PVs are removed. All this should be gradually
+	 * superseded by lvconvert --repair.
+	 */
+	list_iterate_safe(pvh, pvht, &vg->pvs) {
+		pvl = list_item(pvh, struct pv_list);
+		if (pvl->pv->dev)
+			continue;
+		if (!_remove_pv(vg, pvl, 0))
+			return_0;
+	}
 
 	/* FIXME Recovery.  For now people must clean up by hand. */
 

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

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