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

[lvm-devel] [PATCH] (10/11) conflict resolution with hotspare changes



Hi,

this is just an explicit patch doing the conflict resolution, and is mostly for
reference. The vgreduce part has already appeared as part of the previous
patch, the metadata.c bit just clarifies what is the right resolution of the
unresolved conflict that appeared in one of the previous patches.

Yours,
   Petr.

Tue Sep 30 23:40:01 CEST 2008  me mornfall net
  * Fix a botched error check in vgreduce.
Tue Sep 30 23:39:20 CEST 2008  me mornfall net
  * Verbose: say we are about to open a VG for recovery in vgreduce.
Tue Sep 30 23:39:09 CEST 2008  me mornfall net
  * Minor formatting change.
Tue Sep 30 14:42:37 CEST 2008  me mornfall net
  * Resolve conflicts with upstream.
Thu Oct 30 18:35:24 CET 2008  Petr Rockai <me mornfall net>
  tagged base 8-6
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata.c new-lvmlib-b/lib/metadata/metadata.c
--- old-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:38:52.669833328 +0100
+++ new-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:38:52.737837851 +0100
@@ -339,9 +339,9 @@ int vg_remove_single(struct cmd_context 
 	struct pv_list *pvl;
 	int ret = 1;
 
-	if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
-		log_error("Volume group \"%s\" not found or inconsistent.",
-			  vg_name);
+	if (vg_read_error(vg) || vg_missing_pv_count(vg)) {
+		log_error("Volume group \"%s\" not found, is inconsistent "
+			  "or has PVs missing.", vg_name);
 		log_error("Consider vgreduce --removemissing if metadata "
 			  "is inconsistent.");
 		return 0;
diff -rN -p -u old-lvmlib-b/tools/lvremove.c new-lvmlib-b/tools/lvremove.c
--- old-lvmlib-b/tools/lvremove.c	2008-10-30 18:38:52.669833328 +0100
+++ new-lvmlib-b/tools/lvremove.c	2008-10-30 18:38:52.705838113 +0100
@@ -31,6 +31,8 @@ int lvremove(struct cmd_context *cmd, in
 		return EINVALID_CMD_LINE;
 	}
 
-	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
+	cmd->handles_missing_pvs = 1;
+
+	return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, NULL,
 			       &lvremove_single);
 }
diff -rN -p -u old-lvmlib-b/tools/vgreduce.c new-lvmlib-b/tools/vgreduce.c
--- old-lvmlib-b/tools/vgreduce.c	2008-10-30 18:38:52.669833328 +0100
+++ new-lvmlib-b/tools/vgreduce.c	2008-10-30 18:38:52.701838163 +0100
@@ -459,7 +459,8 @@ int vgreduce(struct cmd_context *cmd, in
 	struct volume_group *vg;
 	char *vg_name;
 	int ret = 1;
-	int consistent = 1;
+	int fixed = 1;
+	int repairing = arg_count(cmd, removemissing_ARG);
 
 	if (!argc && !repairing) {
 		log_error("Please give volume group name and "
@@ -505,10 +506,9 @@ int vgreduce(struct cmd_context *cmd, in
 
 	log_verbose("Finding volume group \"%s\"", vg_name);
 
-	if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent) &&
-	    !arg_count(cmd, removemissing_ARG)) {
-		log_error("Volume group \"%s\" doesn't exist", vg_name);
-		unlock_vg(cmd, vg_name);
+	vg = vg_read_for_update(cmd, vg_name, NULL, ALLOW_EXPORTED);
+	if (vg_read_error(vg) == FAILED_ALLOCATION ||
+	    vg_read_error(vg) == FAILED_NOTFOUND)
 		return ECMD_FAILED;
 
 	/* FIXME We want to allow read-only VGs to be changed here? */
@@ -516,22 +516,22 @@ int vgreduce(struct cmd_context *cmd, in
 	    && !arg_count(cmd, removemissing_ARG))
 		return ECMD_FAILED;
 
-	if (arg_count(cmd, removemissing_ARG)) {
-		if (vg && consistent) {
+	if (repairing) {
+		if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
 			log_error("Volume group \"%s\" is already consistent",
 				  vg_name);
 			unlock_vg(cmd, vg_name);
 			return ECMD_PROCESSED;
 		}
 
-		init_partial(1);
-		consistent = 0;
-		if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
-			log_error("Volume group \"%s\" not found", vg_name);
-			unlock_vg(cmd, vg_name);
-			return ECMD_FAILED;
-		}
-		if (!vg_check_status(vg, CLUSTERED)) {
+		log_verbose("Trying to open VG %s for recovery...", vg_name);
+
+		vg = vg_read_for_update(cmd, vg_name, NULL,
+					ALLOW_INCONSISTENT | DISABLE_LOCK
+					| ALLOW_EXPORTED);
+
+		if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
+		    && vg_read_error(vg) != FAILED_INCONSISTENT) {
 			unlock_vg(cmd, vg_name);
 			return ECMD_FAILED;
 		}

-- 
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]