mdadm/test: Convert code format to use Tab
In case to make codes neat, this commit didn't change any codes, just tidy up and use Tab as code format. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
parent
922a58292f
commit
662c349a5a
178
test
178
test
|
@ -3,8 +3,9 @@
|
||||||
# run test suite for mdadm
|
# run test suite for mdadm
|
||||||
user=`id -un`
|
user=`id -un`
|
||||||
if [ " $user" != " root" ]
|
if [ " $user" != " root" ]
|
||||||
then echo >&2 "test: testing can only be done as 'root'."
|
then
|
||||||
exit 1;
|
echo >&2 "test: testing can only be done as 'root'."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prefix='[0-9][0-9]'
|
prefix='[0-9][0-9]'
|
||||||
|
@ -25,7 +26,8 @@ echo "Testing on linux-$(uname -r) kernel"
|
||||||
|
|
||||||
# Check whether to run multipath tests
|
# Check whether to run multipath tests
|
||||||
modprobe multipath 2> /dev/null
|
modprobe multipath 2> /dev/null
|
||||||
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat ; then
|
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat
|
||||||
|
then
|
||||||
MULTIPATH="yes"
|
MULTIPATH="yes"
|
||||||
fi
|
fi
|
||||||
INTEGRITY=yes
|
INTEGRITY=yes
|
||||||
|
@ -36,7 +38,9 @@ LVM_VOLGROUP=mdtest
|
||||||
export MDADM_NO_SYSTEMCTL=1
|
export MDADM_NO_SYSTEMCTL=1
|
||||||
|
|
||||||
# assume md0, md1, md2 exist in /dev
|
# assume md0, md1, md2 exist in /dev
|
||||||
md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
|
md0=/dev/md0
|
||||||
|
md1=/dev/md1
|
||||||
|
md2=/dev/md2
|
||||||
mdp0=/dev/md_d0
|
mdp0=/dev/md_d0
|
||||||
mdp1=/dev/md_d1
|
mdp1=/dev/md_d1
|
||||||
|
|
||||||
|
@ -73,7 +77,7 @@ cleanup() {
|
||||||
loop)
|
loop)
|
||||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
do
|
do
|
||||||
losetup -d /dev/loop$d ; # rm -f $targetdir/mdtest$d
|
losetup -d /dev/loop$d # rm -f $targetdir/mdtest$d
|
||||||
rm -f /dev/disk/by-path/loop*
|
rm -f /dev/disk/by-path/loop*
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
@ -107,10 +111,14 @@ do_setup() {
|
||||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
do
|
do
|
||||||
sz=$size
|
sz=$size
|
||||||
if [ $d -gt 7 ]; then sz=$ddfsize ; fi
|
if [ $d -gt 7 ]
|
||||||
|
then
|
||||||
|
sz=$ddfsize
|
||||||
|
fi
|
||||||
case $DEVTYPE in
|
case $DEVTYPE in
|
||||||
loop)
|
loop)
|
||||||
[ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
|
[ -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
|
# make sure udev doesn't touch
|
||||||
mdadm --zero $targetdir/mdtest$d 2> /dev/null
|
mdadm --zero $targetdir/mdtest$d 2> /dev/null
|
||||||
[ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
|
[ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
|
||||||
|
@ -126,7 +134,8 @@ do_setup() {
|
||||||
lvm)
|
lvm)
|
||||||
unset MULTIPATH
|
unset MULTIPATH
|
||||||
eval dev$d=/dev/mapper/${LVM_VOLGROUP}-mdtest$d
|
eval dev$d=/dev/mapper/${LVM_VOLGROUP}-mdtest$d
|
||||||
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP; then
|
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP
|
||||||
|
then
|
||||||
trap '' 0 # make sure lvremove is not called
|
trap '' 0 # make sure lvremove is not called
|
||||||
eval echo error creating \$dev$d
|
eval echo error creating \$dev$d
|
||||||
exit 129
|
exit 129
|
||||||
|
@ -143,7 +152,6 @@ do_setup() {
|
||||||
done
|
done
|
||||||
path0=$dev6
|
path0=$dev6
|
||||||
path1=$dev7
|
path1=$dev7
|
||||||
|
|
||||||
ulimit -c unlimited
|
ulimit -c unlimited
|
||||||
[ -f /proc/mdstat ] || modprobe md_mod
|
[ -f /proc/mdstat ] || modprobe md_mod
|
||||||
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
|
@ -154,18 +162,26 @@ do_setup() {
|
||||||
mdadm() {
|
mdadm() {
|
||||||
rm -f $targetdir/stderr
|
rm -f $targetdir/stderr
|
||||||
case $* in
|
case $* in
|
||||||
*-S* ) udevadm settle
|
*-S* )
|
||||||
|
udevadm settle
|
||||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||||
echo 20000 > /proc/sys/dev/raid/speed_limit_max
|
echo 20000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
case $* in
|
case $* in
|
||||||
*-C* ) $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes;;
|
*-C* )
|
||||||
* ) $mdadm 2> $targetdir/stderr --quiet "$@"
|
$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
$mdadm 2> $targetdir/stderr --quiet "$@"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
rv=$?
|
rv=$?
|
||||||
case $* in
|
case $* in
|
||||||
*-S* ) udevadm settle
|
*-S* )
|
||||||
|
udevadm settle
|
||||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
cat >&2 $targetdir/stderr
|
cat >&2 $targetdir/stderr
|
||||||
return $rv
|
return $rv
|
||||||
|
@ -178,18 +194,25 @@ check() {
|
||||||
spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
|
spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
|
||||||
if [ $spares -ne $2 ]
|
if [ $spares -ne $2 ]
|
||||||
then
|
then
|
||||||
echo >&2 "ERROR expected $2 spares, found $spares"; exit 1;
|
echo >&2 "ERROR expected $2 spares, found $spares"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
raid* | linear )
|
raid* | linear )
|
||||||
grep -s "active $1 " /proc/mdstat > /dev/null || {
|
grep -s "active $1 " /proc/mdstat > /dev/null || {
|
||||||
echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
|
echo >&2 "ERROR active $1 not found"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
algorithm )
|
algorithm )
|
||||||
grep -s " algorithm $2 " /proc/mdstat > /dev/null || {
|
grep -s " algorithm $2 " /proc/mdstat > /dev/null || {
|
||||||
echo >&2 "ERROR algorithm $2 not found"; cat /proc/mdstat; exit 1;}
|
echo >&2 "ERROR algorithm $2 not found"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
resync | recovery | reshape)
|
resync | recovery | reshape )
|
||||||
cnt=5
|
cnt=5
|
||||||
while ! grep -s $1 /proc/mdstat > /dev/null
|
while ! grep -s $1 /proc/mdstat > /dev/null
|
||||||
do
|
do
|
||||||
|
@ -198,11 +221,12 @@ check() {
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
cnt=$[cnt-1]
|
cnt=$[cnt-1]
|
||||||
else
|
else
|
||||||
echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1
|
echo >&2 ERROR no $1 happening
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
nosync )
|
nosync )
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
# Since 4.2 we delay the close of recovery until there has been a chance for
|
# Since 4.2 we delay the close of recovery until there has been a chance for
|
||||||
|
@ -210,80 +234,105 @@ check() {
|
||||||
# to do can still take a little longer than expected.
|
# to do can still take a little longer than expected.
|
||||||
# add an extra check: is sync_completed shows the end is reached, assume
|
# add an extra check: is sync_completed shows the end is reached, assume
|
||||||
# there is no recovery.
|
# there is no recovery.
|
||||||
if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat ; then
|
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'`
|
incomplete=`grep / /sys/block/md*/md/sync_completed 2> /dev/null | sed '/^ *\([0-9]*\) \/ \1/d'`
|
||||||
if [ -n "$incomplete" ]; then
|
if [ -n "$incomplete" ]
|
||||||
echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1;
|
then
|
||||||
|
echo >&2 "ERROR resync or recovery is happening!"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
wait )
|
wait )
|
||||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||||
echo 2000000 > /proc/sys/dev/raid/speed_limit_max
|
echo 2000000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
while grep -E '(resync|recovery|reshape|check|repair) *=' > /dev/null /proc/mdstat ||
|
while grep -E '(resync|recovery|reshape|check|repair) *=' > /dev/null /proc/mdstat ||
|
||||||
grep -v idle > /dev/null /sys/block/md*/md/sync_action
|
grep -v idle > /dev/null /sys/block/md*/md/sync_action
|
||||||
do sleep 0.5;
|
do
|
||||||
|
sleep 0.5
|
||||||
done
|
done
|
||||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||||
;;
|
;;
|
||||||
|
|
||||||
state )
|
state )
|
||||||
grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
|
grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
|
||||||
echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; }
|
echo >&2 "ERROR state $2 not found!"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
;;
|
;;
|
||||||
|
|
||||||
bitmap )
|
bitmap )
|
||||||
grep -s bitmap > /dev/null /proc/mdstat || {
|
grep -s bitmap > /dev/null /proc/mdstat || {
|
||||||
echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
|
echo >&2 ERROR no bitmap
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
nobitmap )
|
nobitmap )
|
||||||
if grep -s "bitmap" > /dev/null /proc/mdstat
|
if grep -s "bitmap" > /dev/null /proc/mdstat
|
||||||
then
|
then
|
||||||
echo >&2 ERROR bitmap present ; cat /proc/mdstat ; exit 1;
|
echo >&2 ERROR bitmap present
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
readonly )
|
readonly )
|
||||||
grep -s "read-only" > /dev/null /proc/mdstat || {
|
grep -s "read-only" > /dev/null /proc/mdstat || {
|
||||||
echo >&2 "ERROR array is not read-only!"; cat /proc/mdstat ; exit 1; }
|
echo >&2 "ERROR array is not read-only!"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
inactive )
|
inactive )
|
||||||
grep -s "inactive" > /dev/null /proc/mdstat || {
|
grep -s "inactive" > /dev/null /proc/mdstat || {
|
||||||
echo >&2 "ERROR array is not inactive!"; cat /proc/mdstat ; exit 1; }
|
echo >&2 "ERROR array is not inactive!"
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo >&2 ERROR unknown check $1
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
* ) echo >&2 ERROR unknown check $1 ; exit 1;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
no_errors() {
|
no_errors() {
|
||||||
if [ -s $targetdir/stderr ]
|
if [ -s $targetdir/stderr ]
|
||||||
then echo Bad errors from mdadm: ; cat $targetdir/stderr; exit 2;
|
then
|
||||||
|
echo Bad errors from mdadm:
|
||||||
|
cat $targetdir/stderr
|
||||||
|
exit 2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# basic device test
|
|
||||||
|
|
||||||
|
# basic device test
|
||||||
testdev() {
|
testdev() {
|
||||||
udevadm settle
|
udevadm settle
|
||||||
dev=$1
|
dev=$1
|
||||||
cnt=$2
|
cnt=$2
|
||||||
dvsize=$3
|
dvsize=$3
|
||||||
chunk=$4
|
chunk=$4
|
||||||
if [ -z "$5" ]; then
|
if [ -z "$5" ]
|
||||||
|
then
|
||||||
mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
|
mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
|
||||||
fi
|
fi
|
||||||
dsize=$[dvsize/chunk]
|
dsize=$[dvsize/chunk]
|
||||||
dsize=$[dsize*chunk]
|
dsize=$[dsize*chunk]
|
||||||
rasize=$[dsize*2*cnt]
|
rasize=$[dsize*2*cnt]
|
||||||
# rasize is in sectors
|
# rasize is in sectors
|
||||||
if [ -n "$DEV_ROUND_K" ]; then
|
if [ -n "$DEV_ROUND_K" ]
|
||||||
|
then
|
||||||
rasize=$[rasize/DEV_ROUND_K/2]
|
rasize=$[rasize/DEV_ROUND_K/2]
|
||||||
rasize=$[rasize*DEV_ROUND_K*2]
|
rasize=$[rasize*DEV_ROUND_K*2]
|
||||||
fi
|
fi
|
||||||
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]; then sleep 2 ; fi
|
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]
|
||||||
|
then
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
_sz=`/sbin/blockdev --getsize $dev`
|
_sz=`/sbin/blockdev --getsize $dev`
|
||||||
if [ $rasize -lt $_sz -o $[rasize*4/5] -gt $_sz ]
|
if [ $rasize -lt $_sz -o $[rasize*4/5] -gt $_sz ]
|
||||||
then
|
then
|
||||||
|
@ -332,10 +381,12 @@ do_test() {
|
||||||
echo "FAILED - see $logdir/$log for details"
|
echo "FAILED - see $logdir/$log for details"
|
||||||
_fail=1
|
_fail=1
|
||||||
fi
|
fi
|
||||||
if [ "$savelogs" == "1" ]; then
|
if [ "$savelogs" == "1" ]
|
||||||
|
then
|
||||||
cp $targetdir/log $logdir/$_basename.log
|
cp $targetdir/log $logdir/$_basename.log
|
||||||
fi
|
fi
|
||||||
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]; then
|
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]
|
||||||
|
then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -361,59 +412,60 @@ parse_args() {
|
||||||
for i in $*
|
for i in $*
|
||||||
do
|
do
|
||||||
case $i in
|
case $i in
|
||||||
[0-9]*)
|
[0-9]* )
|
||||||
prefix=$i
|
prefix=$i
|
||||||
;;
|
;;
|
||||||
setup)
|
setup )
|
||||||
echo "mdadm test environment setup"
|
echo "mdadm test environment setup"
|
||||||
do_setup
|
do_setup
|
||||||
trap 0; exit 0
|
trap 0
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
cleanup)
|
cleanup )
|
||||||
cleanup
|
cleanup
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--tests=*)
|
--tests=* )
|
||||||
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
||||||
;;
|
;;
|
||||||
--logdir=*)
|
--logdir=* )
|
||||||
logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||||
;;
|
;;
|
||||||
--save-logs)
|
--save-logs )
|
||||||
savelogs=1
|
savelogs=1
|
||||||
;;
|
;;
|
||||||
--keep-going | --no-error)
|
--keep-going | --no-error )
|
||||||
exitonerror=0
|
exitonerror=0
|
||||||
;;
|
;;
|
||||||
--disable-multipath)
|
--disable-multipath )
|
||||||
unset MULTIPATH
|
unset MULTIPATH
|
||||||
;;
|
;;
|
||||||
--disable-integrity)
|
--disable-integrity )
|
||||||
unset INTEGRITY
|
unset INTEGRITY
|
||||||
;;
|
;;
|
||||||
--dev=loop)
|
--dev=loop )
|
||||||
DEVTYPE=loop
|
DEVTYPE=loop
|
||||||
;;
|
;;
|
||||||
--dev=lvm)
|
--dev=lvm )
|
||||||
DEVTYPE=lvm
|
DEVTYPE=lvm
|
||||||
;;
|
;;
|
||||||
--dev=ram)
|
--dev=ram )
|
||||||
DEVTYPE=ram
|
DEVTYPE=ram
|
||||||
;;
|
;;
|
||||||
--volgroup=*)
|
--volgroup=* )
|
||||||
LVM_VOLGROUP=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
LVM_VOLGROUP=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||||
;;
|
;;
|
||||||
--help)
|
--help )
|
||||||
do_help
|
do_help
|
||||||
exit 0;
|
exit 0
|
||||||
;;
|
;;
|
||||||
-*)
|
-* )
|
||||||
echo " $0: Unknown argument: $i"
|
echo " $0: Unknown argument: $i"
|
||||||
do_help
|
do_help
|
||||||
exit 0;
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
logdir=$targetdir
|
logdir=$targetdir
|
||||||
|
@ -422,11 +474,13 @@ parse_args $@
|
||||||
do_setup
|
do_setup
|
||||||
mkdir -p $logdir
|
mkdir -p $logdir
|
||||||
|
|
||||||
if [ "$savelogs" == "1" ]; then
|
if [ "$savelogs" == "1" ]
|
||||||
|
then
|
||||||
echo "Saving logs to $logdir"
|
echo "Saving logs to $logdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x$TESTLIST" != "x" ]; then
|
if [ "x$TESTLIST" != "x" ]
|
||||||
|
then
|
||||||
for script in $TESTLIST
|
for script in $TESTLIST
|
||||||
do
|
do
|
||||||
do_test $testdir/$script
|
do_test $testdir/$script
|
||||||
|
|
Loading…
Reference in New Issue