]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - test
Fix RAID metadata check
[thirdparty/mdadm.git] / test
diff --git a/test b/test
index d268433eb73db166b6af634ce12ac6e472b2e961..13f1bda71d0ae0ef1dae9a8c2492cfd60b07d00e 100755 (executable)
--- a/test
+++ b/test
@@ -111,6 +111,8 @@ do_setup() {
     case $DEVTYPE in
     loop)
       [ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
+      # make sure udev doesn't touch
+      mdadm --zero $targetdir/mdtest$d 2> /dev/null
       [ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
       if [ $d -eq 7 ]
       then
@@ -154,7 +156,7 @@ mdadm() {
     case $* in
        *-S* ) udevadm settle
               p=`cat /proc/sys/dev/raid/speed_limit_max`
-              echo 2000000 > /proc/sys/dev/raid/speed_limit_max
+              echo 20000 > /proc/sys/dev/raid/speed_limit_max
     esac
     case $* in
        *-C* ) $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes;;
@@ -203,8 +205,16 @@ check() {
 
      nosync )
        sleep 0.5
+       # Since 4.2 we delay the close of recovery until there has been a chance for
+       # spares to be activated.  That means that a recovery that finds nothing
+       # to do can still take a little longer than expected.
+       # add an extra check: is sync_completed shows the end is reached, assume
+       # there is no recovery.
        if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat ; then
+          incomplete=`grep / /sys/block/md*/md/sync_completed 2> /dev/null | sed '/^ *\([0-9]*\) \/ \1/d'`
+          if [ -n "$incomplete" ]; then
                echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1;
+          fi
        fi
      ;;
 
@@ -236,6 +246,15 @@ check() {
        fi
       ;;
 
+    readonly )
+       grep -s "read-only" > /dev/null /proc/mdstat || {
+                echo >&2 "ERROR array is not read-only!"; cat /proc/mdstat ; exit 1; }
+      ;;
+
+    inactive )
+       grep -s "inactive" > /dev/null /proc/mdstat || {
+                echo >&2 "ERROR array is not inactive!"; cat /proc/mdstat ; exit 1; }
+      ;;
     * ) echo >&2 ERROR unknown check $1 ; exit 1;
    esac
 }
@@ -254,7 +273,7 @@ testdev() {
    dvsize=$3
    chunk=$4
    if [ -z "$5" ]; then
-      mkfs -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
+      mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
    fi
    dsize=$[dvsize/chunk]
    dsize=$[dsize*chunk]
@@ -308,9 +327,9 @@ do_test() {
       dmesg | tail -n 200 >> $targetdir/log
       if [ $exitonerror == 0 ]; then
          log=log-`basename $_script`
-         mv $targetdir/log $targetdir/$log
+         mv $targetdir/log $logdir/$log
       fi
-      echo "FAILED - see $targetdir/$log for details"
+      echo "FAILED - see $logdir/$log for details"
       _fail=1
     fi
     if [ "$savelogs" == "1" ]; then
@@ -362,12 +381,6 @@ parse_args() {
       ;;
     --save-logs)
       savelogs=1
-      if [ ! -d $logdir ] ; then
-        mkdir $logdir
-        if [ $? -ne 0 ] ; then
-         exit 1;
-       fi
-      fi
       ;;
     --keep-going | --no-error)
       exitonerror=0
@@ -403,9 +416,11 @@ parse_args() {
 done
 }
 
+logdir=$targetdir
 parse_args $@
 
 do_setup
+mkdir -p $logdir
 
 if [ "$savelogs" == "1" ]; then
   echo "Saving logs to $logdir"