]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add test for stoping and restarting a raid5 reshape.
authorNeil Brown <neilb@suse.de>
Fri, 27 Jun 2008 06:07:52 +0000 (16:07 +1000)
committerNeil Brown <neilb@suse.de>
Fri, 27 Jun 2008 06:07:52 +0000 (16:07 +1000)
There was a kernel bug with stopping and restarting
raid5 recently.  So add a test to check for it.

Grow.c
test
tests/07reshape5intr [new file with mode: 0644]

diff --git a/Grow.c b/Grow.c
index b24e9587c192c8a1e96b42e46d2c167ee87290f8..c2eae32bbb5645fb0744cfc1f3544d047813d243 100644 (file)
--- 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 a62d7e319f7343dc4c9d89006c738c893c49ce2c..1a79bab42295102a8731d854d75e3997b32f1bf1 100644 (file)
--- 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 (file)
index 0000000..e2a3560
--- /dev/null
@@ -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