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

[lvm-devel] [PATCH] Rename mirror_device_fault_policy to mirror_image_fault policy



This should be quite simple, but I have thrown in a simple testcase as
well, for a good measure. There is some code duplication, but I'll
address that separately, since the old codepath (which does not really
do any upconversion, just logs suggestions) is still employed by
vgreduce --removemissing --force. This ought to be simplified to just
remove the faulty images/logs without looking at the policy or writing
any hints (vgreduce --removemissing should issue a hint about lvconvert
--repair instead).

This should fix RHBZ 538620.

Yours,
   Petr.

diff -rN -u -p old-policy-conf/doc/example.conf new-policy-conf/doc/example.conf
--- old-policy-conf/doc/example.conf	2009-12-20 15:43:25.000000000 +0100
+++ new-policy-conf/doc/example.conf	2009-12-20 15:43:25.000000000 +0100
@@ -405,7 +405,7 @@ activation {
     #            be allocated for the replacement.
 
     mirror_log_fault_policy = "allocate"
-    mirror_device_fault_policy = "remove"
+    mirror_image_fault_policy = "remove"
 }
 
 
diff -rN -u -p old-policy-conf/lib/config/defaults.h new-policy-conf/lib/config/defaults.h
--- old-policy-conf/lib/config/defaults.h	2009-12-20 15:43:25.000000000 +0100
+++ new-policy-conf/lib/config/defaults.h	2009-12-20 15:43:25.000000000 +0100
@@ -46,7 +46,7 @@
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
-#define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
+#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
 #define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
 #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
 #define DEFAULT_DMEVENTD_MONITOR 1
diff -rN -u -p old-policy-conf/lib/metadata/mirror.c new-policy-conf/lib/metadata/mirror.c
--- old-policy-conf/lib/metadata/mirror.c	2009-12-20 15:43:25.000000000 +0100
+++ new-policy-conf/lib/metadata/mirror.c	2009-12-20 15:43:25.000000000 +0100
@@ -781,9 +781,13 @@ static int get_mirror_fault_policy(struc
 	if (log_policy)
 		policy = find_config_str(NULL, "activation/mirror_log_fault_policy",
 					 DEFAULT_MIRROR_LOG_FAULT_POLICY);
-	else
-		policy = find_config_str(NULL, "activation/mirror_device_fault_policy",
-					 DEFAULT_MIRROR_DEV_FAULT_POLICY);
+	else {
+		policy = find_config_str(NULL, "activation/mirror_image_fault_policy",
+					 NULL);
+		if (!policy)
+			policy = find_config_str(NULL, "activation/mirror_device_fault_policy",
+						 DEFAULT_MIRROR_IMAGE_FAULT_POLICY);
+	}
 
 	if (!strcmp(policy, "remove"))
 		return MIRROR_REMOVE;
diff -rN -u -p old-policy-conf/test/t-lvconvert-repair-policy.sh new-policy-conf/test/t-lvconvert-repair-policy.sh
--- old-policy-conf/test/t-lvconvert-repair-policy.sh	1970-01-01 01:00:00.000000000 +0100
+++ new-policy-conf/test/t-lvconvert-repair-policy.sh	2009-12-20 15:43:25.000000000 +0100
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+. ./test-utils.sh
+
+prepare_vg 4
+
+cleanup() {
+	vgreduce --removemissing $vg
+	enable_dev $dev1
+	vgextend $vg $dev1
+	lvremove -ff $vg/mirror
+	lvcreate -m 1 -L 1 -n mirror $vg
+}
+
+lvcreate -m 1 -L 1 -n mirror $vg
+lvchange -a n $vg/mirror
+disable_dev $dev1
+lvchange --partial -a y $vg/mirror
+
+lvconvert -i 1 --repair --use-policies --config 'activation/mirror_image_fault_policy = "remove"' $vg/mirror
+
+lvs | grep -- -wi-a- # non-mirror
+cleanup
+
+disable_dev $dev1
+lvconvert -i 1 --repair --use-policies --config 'activation/mirror_image_fault_policy = "replace"' $vg/mirror
+lvs | grep -- mwi-a- # mirror
+cleanup
+
+disable_dev $dev1
+lvconvert -i 1 --repair --use-policies --config 'activation/mirror_device_fault_policy = "replace"' $vg/mirror
+lvs | grep -- mwi-a- # mirror
+cleanup
diff -rN -u -p old-policy-conf/tools/lvconvert.c new-policy-conf/tools/lvconvert.c
--- old-policy-conf/tools/lvconvert.c	2009-12-20 15:43:25.000000000 +0100
+++ new-policy-conf/tools/lvconvert.c	2009-12-20 15:43:25.000000000 +0100
@@ -465,6 +465,9 @@ static void _lvconvert_mirrors_repair_as
 
 	if (arg_count(cmd, use_policies_ARG)) {
 		leg_policy = find_config_tree_str(cmd,
+					"activation/mirror_image_fault_policy", NULL);
+		if (!leg_policy)
+			leg_policy = find_config_tree_str(cmd,
 					"activation/mirror_device_fault_policy",
 					DEFAULT_MIRROR_DEVICE_FAULT_POLICY);
 		log_policy = find_config_tree_str(cmd,

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