2009-02-23 22:26:10 +01:00
|
|
|
imsm_check_hold() {
|
|
|
|
if [ mdadm --remove $1 $2 -eq 0 ]; then
|
|
|
|
echo "$2 removal from $1 should have been blocked" >&2
|
|
|
|
cat /proc/mdstat >&2
|
|
|
|
mdadm -E $2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
imsm_check_removal() {
|
|
|
|
if [ mdadm --remove $1 $2 -ne 0 ]; then
|
|
|
|
echo "$2 removal from $1 should have succeeded" >&2
|
|
|
|
cat /proc/mdstat >&2
|
|
|
|
mdadm -E $2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-12-09 00:59:19 +01:00
|
|
|
imsm_check() {
|
|
|
|
case $1 in
|
|
|
|
container )
|
|
|
|
grep -s "$(((418 * $2)/2)) blocks super external:imsm" /proc/mdstat > /dev/null || {
|
|
|
|
echo >&2 "ERROR correctly formed container not found"; cat /proc/mdstat; exit 1;}
|
|
|
|
;;
|
|
|
|
member )
|
|
|
|
member=$2
|
|
|
|
num_disks=$3
|
|
|
|
level=$4
|
|
|
|
size=$5
|
|
|
|
offset=$6
|
2009-02-23 22:26:10 +01:00
|
|
|
chunk=$7
|
2008-12-09 00:59:19 +01:00
|
|
|
err=0
|
|
|
|
|
2009-02-23 22:26:10 +01:00
|
|
|
if [ $level -ne 1 ]; then
|
|
|
|
size=$((size & ~(chunk - 1)))
|
|
|
|
else
|
|
|
|
chunk=64
|
|
|
|
fi
|
2008-12-09 00:59:19 +01:00
|
|
|
eval `stat -L -c "let major=0x%t; let minor=0x%T;" $member`
|
|
|
|
sysfs=/sys/dev/block/${major}:${minor}
|
|
|
|
if [ ! -f ${sysfs}/md/array_state ]; then
|
|
|
|
echo "member array $member not found" >&2
|
|
|
|
cat /proc/mdstat >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-02-23 22:26:10 +01:00
|
|
|
_chunk=`cat ${sysfs}/md/chunk_size`
|
|
|
|
if [ $chunk -ne $((_chunk/1024)) ]; then
|
|
|
|
echo "chunk mismatch expected $chunk got $_chunk" >&2
|
|
|
|
err=$((err+1))
|
|
|
|
fi
|
2008-12-09 00:59:19 +01:00
|
|
|
for i in `seq 0 $((num_disks-1))`
|
|
|
|
do
|
|
|
|
_offset=`cat ${sysfs}/md/rd${i}/offset`
|
|
|
|
if [ $offset -ne $((_offset/2)) ]; then
|
|
|
|
echo "offset mismatch expected $offset got $_offset" >&2
|
|
|
|
err=$((err+1))
|
|
|
|
fi
|
|
|
|
_size=`cat ${sysfs}/md/rd${i}/size`
|
|
|
|
if [ $size -ne $_size ]; then
|
2009-02-23 22:26:10 +01:00
|
|
|
echo "size mismatch expected $size got $_size" >&2
|
2008-12-09 00:59:19 +01:00
|
|
|
err=$((err+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $err -gt 0 ]; then
|
|
|
|
echo "$member failed check" >&2
|
|
|
|
cat /proc/mdstat >&2
|
|
|
|
mdadm -E /dev/loop0 >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
* ) echo >&2 ERROR unknown check $1 ; exit 1;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_env() {
|
|
|
|
export IMSM_DEVNAME_AS_SERIAL=1
|
2009-02-23 22:26:10 +01:00
|
|
|
export IMSM_TEST_OROM=1
|
2008-12-09 00:59:19 +01:00
|
|
|
container=/dev/md/container
|
|
|
|
member0=/dev/md/vol0
|
|
|
|
member1=/dev/md/vol1
|
|
|
|
member2=/dev/md/vol2
|
|
|
|
member3=/dev/md/vol3
|
|
|
|
member4=/dev/md/vol4
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_env() {
|
|
|
|
unset IMSM_DEVNAME_AS_SERIAL
|
2009-02-23 22:26:10 +01:00
|
|
|
unset IMSM_TEST_OROM
|
2008-12-09 00:59:19 +01:00
|
|
|
unset imsm_check
|
|
|
|
unset container
|
|
|
|
unset member0
|
|
|
|
unset member1
|
|
|
|
unset member2
|
|
|
|
unset member3
|
|
|
|
unset member4
|
|
|
|
}
|