Neil Brown: Add test for stoping and restarting a raid5 reshape.

Martin F. Krafft madduck at alioth.debian.org
Mon Feb 16 11:24:07 UTC 2009


Module: mdadm
Branch: build
Commit: 0aa389dc6232370241d6efa811e7fbc59c0dd2a7
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=0aa389dc6232370241d6efa811e7fbc59c0dd2a7

Author: Neil Brown <neilb at suse.de>
Date:   Fri Jun 27 16:07:52 2008 +1000

Add test for stoping and restarting a raid5 reshape.

There was a kernel bug with stopping and restarting
raid5 recently.  So add a test to check for it.

---

 Grow.c               |    5 +++--
 test                 |    9 ++++++---
 tests/07reshape5intr |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/Grow.c b/Grow.c
index b24e958..c2eae32 100644
--- a/Grow.c
+++ b/Grow.c
@@ -615,7 +615,8 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 			last_block = nstripe * ndata;
 			ostripe = last_block / odata / (ochunk/512) * (ochunk/512);
 		}
-		printf("mdadm: Need to backup %lluK of critical section..\n", last_block/2);
+		fprintf(stderr, Name ": Need to backup %lluK of critical "
+			"section..\n", last_block/2);
 
 		sra = sysfs_read(fd, 0,
 				 GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|
@@ -837,7 +838,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 		if (backup_file)
 			unlink(backup_file);
 
-		printf(Name ": ... critical section passed.\n");
+		fprintf(stderr, Name ": ... critical section passed.\n");
 		break;
 	}
 	return 0;
diff --git a/test b/test
index a62d7e3..1a79bab 100644
--- a/test
+++ b/test
@@ -67,6 +67,9 @@ done
 path0=$dev6
 path1=$dev7
 
+echo 2000 > /proc/sys/dev/raid/speed_limit_max
+echo 0 > /sys/module/md_mod/parameters/start_ro
+
 if [ " $1" = " setup" ]
 then trap 0 ; exit 0
 fi
@@ -95,7 +98,7 @@ check() {
       grep -s "active $1 " /proc/mdstat > /dev/null || {
    		echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
      ;;
-    resync | recovery )
+    resync | recovery | reshape)
       sleep 0.5
       grep -s $1 /proc/mdstat > /dev/null || {
    		echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; }
@@ -103,14 +106,14 @@ check() {
    
      nosync )
        sleep 0.5
-       if grep -s 're[synccovery]* =' > /dev/null /proc/mdstat ; then
+       if grep -s -E '(resync|recovery|reshape) =' > /dev/null /proc/mdstat ; then
    	   echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1; 
        fi
      ;;
    
     wait )
       sleep 0.1
-      while grep 're[synccovery]* =' > /dev/null /proc/mdstat
+      while grep -E '(resync|recovery|reshape|check|repair) =' > /dev/null /proc/mdstat
       do sleep 2;
       done
       ;;
diff --git a/tests/07reshape5intr b/tests/07reshape5intr
new file mode 100644
index 0000000..e2a3560
--- /dev/null
+++ b/tests/07reshape5intr
@@ -0,0 +1,33 @@
+
+#
+# test interrupting and restartign raid5 reshape.
+set -x
+devs="$dev1"
+st=UU
+for disks in 2 3 4 5
+do
+  eval devs=\"$devs \$dev$disks\"
+  st=U$st
+  for d in $devs
+  do dd if=/dev/urandom of=$d bs=1024 || true
+  done
+
+  $mdadm -CR $md0 -amd -l5 -n$disks --assume-clean $devs
+  $mdadm $md0 --add $dev6
+  echo 20 > /proc/sys/dev/raid/speed_limit_max
+  $mdadm --grow $md0 -n $[disks+1]
+  check reshape
+  check state $st
+  $mdadm --stop $md0
+  $mdadm --assemble $md0 $devs $dev6
+  check reshape
+  echo 2000 > /proc/sys/dev/raid/speed_limit_max
+  check wait
+  echo check > /sys/block/md0/md/sync_action
+  check wait
+  mm=`cat /sys/block/md0/md/mismatch_cnt`
+  if [ $mm -gt 0 ]
+  then echo >&2 "ERROR mismatch_cnt non-zero : $mm" ; exit 1
+  fi
+  $mdadm -S $md0
+done




More information about the pkg-mdadm-commits mailing list