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

[lvm-devel] [PATCH] LVM2 RFC: fix return code when exclusive activation fails



I've attached this patch to the bugzilla

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=208993

but I've yet to have any feed back on it, so I thought I'd post it here too.

Possibly the most controversial part of it (I suspect) will be the shifting up of the return codes, this is needed to
keep INCOMPLETE in its rightful place in the severity stakes

patrick
Index: lib/commands/errors.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/commands/errors.h,v
retrieving revision 1.4
diff -u -p -r1.4 errors.h
--- lib/commands/errors.h	30 Mar 2004 19:35:37 -0000	1.4
+++ lib/commands/errors.h	3 Jan 2007 16:01:05 -0000
@@ -17,8 +17,9 @@
 #define _LVM_ERRORS_H
 
 #define ECMD_PROCESSED		1
-#define ENO_SUCH_CMD		2
-#define EINVALID_CMD_LINE	3
+#define ECMD_INCOMPLETE		2
+#define ENO_SUCH_CMD		3
+#define EINVALID_CMD_LINE	4
 #define ECMD_FAILED		5
 
 #endif
Index: tools/vgchange.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/vgchange.c,v
retrieving revision 1.54
diff -u -p -r1.54 vgchange.c
--- tools/vgchange.c	16 Aug 2006 14:41:42 -0000	1.54
+++ tools/vgchange.c	3 Jan 2007 16:01:05 -0000
@@ -61,7 +61,7 @@ static int _register_lvs_in_vg(struct cm
 }
 
 static int _activate_lvs_in_vg(struct cmd_context *cmd,
-			       struct volume_group *vg, int activate)
+			       struct volume_group *vg, int activate, int *incomplete)
 {
 	struct lv_list *lvl;
 	struct logical_volume *lv;
@@ -82,19 +82,29 @@ static int _activate_lvs_in_vg(struct cm
 			continue;
 
 		if (activate == CHANGE_AN) {
-			if (!deactivate_lv(cmd, lv))
+			if (!deactivate_lv(cmd, lv)) {
+				incomplete++;
 				continue;
+			}
 		} else if (activate == CHANGE_ALN) {
-			if (!deactivate_lv_local(cmd, lv))
+			if (!deactivate_lv_local(cmd, lv)) {
+				incomplete++;
 				continue;
+			}
 		} else if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
-			if (!activate_lv_excl(cmd, lv))
+			if (!activate_lv_excl(cmd, lv)) {
+				incomplete++;
 				continue;
+			}
 		} else if (activate == CHANGE_ALY) {
-			if (!activate_lv_local(cmd, lv))
+			if (!activate_lv_local(cmd, lv)) {
+				incomplete++;
 				continue;
-		} else if (!activate_lv(cmd, lv))
+			}
+		} else if (!activate_lv(cmd, lv)) {
+			incomplete++;
 			continue;
+		}
 
 		if ((lv->status & PVMOVE) &&
 		    (pvname = get_pvmove_pvname_from_lv_mirr(lv))) {
@@ -129,6 +139,7 @@ static int _vgchange_available(struct cm
 	int lv_open, active, monitored;
 	int available;
 	int activate = 1;
+	int incomplete = 0;
 
 	available = arg_uint_value(cmd, available_ARG, 0);
 
@@ -162,17 +173,20 @@ static int _vgchange_available(struct cm
 			    dmeventd_register_mode() ? "" : "un");
 	}
 
-	if (activate && _activate_lvs_in_vg(cmd, vg, available))
+	if (activate && _activate_lvs_in_vg(cmd, vg, available, &incomplete))
 		log_verbose("Activated logical volumes in "
 			    "volume group \"%s\"", vg->name);
 
-	if (!activate && _activate_lvs_in_vg(cmd, vg, available))
+	if (!activate && _activate_lvs_in_vg(cmd, vg, available, &incomplete))
 		log_verbose("Deactivated logical volumes in "
 			    "volume group \"%s\"", vg->name);
 
 	log_print("%d logical volume(s) in volume group \"%s\" now active",
 		  lvs_in_vg_activated(vg), vg->name);
-	return ECMD_PROCESSED;
+	if (incomplete)
+		return ECMD_INCOMPLETE;
+	else
+		return ECMD_PROCESSED;
 }
 
 static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)

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