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

[lvm-devel] [PATCH] Make vgck warn about missing PVs.



Hi,

this is in response to bug #617972 -- read-only commands usually don't
fail when PVs are missing, with the exception of (some cases of)
activation. Since there is demand for programatically checking (without
altering anything) whether a VG is in a good condition, vgck seems like
the right place for this.

I have tweaked tests to cover this functionality, too (one new and one
augmented).

Yours,
   Petr.

Index: tools/vgck.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/vgck.c,v
retrieving revision 1.26
diff -u -p -r1.26 vgck.c
--- tools/vgck.c	9 Jul 2010 15:34:48 -0000	1.26
+++ tools/vgck.c	27 Jul 2010 17:02:09 -0000
@@ -31,6 +31,12 @@ static int vgck_single(struct cmd_contex
 		return ECMD_FAILED;
 	}
 
+	if (vg_missing_pv_count(vg)) {
+		log_warn("WARNING: The volume group is missing %d physical volumes.",
+			 vg_missing_pv_count(vg));
+		return ECMD_FAILED;
+	}
+
 	return ECMD_PROCESSED;
 }
 
Index: test/t-nomda-missing.sh
===================================================================
RCS file: test/t-nomda-missing.sh
diff -N test/t-nomda-missing.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ test/t-nomda-missing.sh	27 Jul 2010 17:02:09 -0000
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+. ./test-utils.sh
+
+prepare_devs 4
+pvcreate $dev1 $dev2
+pvcreate --metadatacopies 0 $dev3 $dev4
+vgcreate $vg $dev1 $dev2 $dev3 $dev4
+
+lvcreate -l1 -n linear1 $vg $dev1
+lvcreate -l1 -n linear2 $vg $dev2
+lvcreate -l2 -n linear12 $vg $dev1:4 $dev2:4
+
+lvcreate -l1 -n origin1 $vg $dev1
+lvcreate -s $vg/origin1 -l1 -n s_napshot2 $dev2
+
+lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg $dev1 $dev2
+lvcreate -l1 -m1 -n mirror123 $vg $dev1 $dev2 $dev3
+
+vgchange -a n $vg
+disable_dev $dev1
+not vgchange -a y $vg
+not vgck $vg
+
+check inactive $vg linear1
+check active $vg linear2
+check inactive $vg origin1
+check inactive $vg s_napshot2
+check inactive $vg linear12
+check inactive $vg mirror12
+check inactive $vg mirror123
+
+vgchange -a n $vg
+enable_dev $dev1
+disable_dev $dev2
+not vgchange -a y $vg
+not vgck $vg
+
+check active $vg linear1
+check inactive $vg linear2
+check inactive $vg linear12
+check inactive $vg origin1
+check inactive $vg s_napshot2
+check inactive $vg mirror12
+check inactive $vg mirror123
+
+vgchange -a n $vg
+enable_dev $dev2
+disable_dev $dev3
+not vgchange -a y $vg
+not vgck $vg
+
+check active $vg origin1
+check active $vg s_napshot2
+check active $vg linear1
+check active $vg linear2
+check active $vg linear12
+check inactive $vg mirror123
+check active $vg mirror12
+
+vgchange -a n $vg
+enable_dev $dev3
+disable_dev $dev4
+vgchange -a y $vg
+not vgck $vg
+
+check active $vg origin1
+check active $vg s_napshot2
+check active $vg linear1
+check active $vg linear2
+check active $vg linear12
+check active $vg mirror12
+check active $vg mirror123
Index: test/t-activate-missing.sh
===================================================================
RCS file: /cvs/lvm2/LVM2/test/t-activate-missing.sh,v
retrieving revision 1.1
diff -u -p -r1.1 t-activate-missing.sh
--- test/t-activate-missing.sh	12 May 2010 06:02:28 -0000	1.1
+++ test/t-activate-missing.sh	27 Jul 2010 17:02:09 -0000
@@ -24,6 +24,7 @@ lvcreate -l1 -m1 -n mirror123 $vg $dev1 
 vgchange -a n $vg
 disable_dev $dev1
 not vgchange -a y $vg
+not vgck $vg
 
 check inactive $vg linear1
 check active $vg linear2
@@ -37,6 +38,7 @@ vgchange -a n $vg
 enable_dev $dev1
 disable_dev $dev2
 not vgchange -a y $vg
+not vgck $vg
 
 check active $vg linear1
 check inactive $vg linear2
@@ -50,6 +52,7 @@ vgchange -a n $vg
 enable_dev $dev2
 disable_dev $dev3
 not vgchange -a y $vg
+not vgck $vg
 
 check active $vg origin1
 check active $vg s_napshot2
@@ -63,6 +66,7 @@ vgchange -a n $vg
 enable_dev $dev3
 disable_dev $dev4
 vgchange -a y $vg
+not vgck $vg
 
 check active $vg origin1
 check active $vg s_napshot2

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