#!/bin/sh # Trigger a "Superblock check-hash failed: recorded check-hash 0x1ef81467 != computed check-hash 0xbfa79b5b" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 mntpoint=/mnt mdstart=10 gmirror load > /dev/null 2>&1 && unload=1 [ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; } old=`sysctl -n kern.geom.mirror.debug` sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 || sysctl kern.geom.mirror.debug=$old > /dev/null u1=$mdstart s=0 [ -c /dev/md$u1 ] && mdconfig -d -u $u1 mdconfig -a -t swap -s 1g -u $u1 set -e ( gpart create -s GPT md$u1 gpart add -t freebsd-ufs -s 341m md$u1 gpart add -t freebsd-ufs -s 341m md$u1 gpart add -t freebsd-ufs -s 341m md$u1 ) > /dev/null gmirror label test md${u1}p1 md${u1}p2 md${u1}p3 [ "`sysctl -in kern.geom.mirror.launch_mirror_before_timeout`" = "0" ] && sleep $((`sysctl -n kern.geom.mirror.timeout` + 1)) [ -c /dev/mirror/test ] || exit 1 newfs /dev/mirror/test > /dev/null mount /dev/mirror/test $mntpoint set +e chmod 777 $mntpoint last=`tail -1 /var/log/messages | cut -c1-15` [ -z "$last" ] && last=dummy sleep 2 cont=/tmp/graid1_7.cont touch $cont for i in `jot 150`; do mkdir -p $mntpoint/$i cd $mntpoint/$i while [ -f $cont ]; do rm -rf $mntpoint/$i/*; jot 300 | \ xargs -I \% cp /etc/group \%; done & done cd /tmp for i in `jot 8`; do while [ -f $cont ]; do for u in md${u1}p2 md${u1}p3; do gmirror forget test gmirror remove test $u gmirror insert test $u id=`gmirror status test | grep gptid | awk '{print $1}'` if [ $i -eq 1 -a -n "$id" ]; then echo "FAIL Remove component $id" gmirror remove test $id fi done 2>/dev/null done & done sleep 300 rm $cont wait gmirror status test | grep -qw md${u1}p2 || gmirror insert test md${u1}p2 gmirror status test | grep -qw md${u1}p3 || gmirror insert test md${u1}p3 i=0 while ! gmirror status test | grep -q COMPLETE; do sleep 5 if [ $((i += 1)) -gt 20 ]; then echo "FAIL to COMPLETE" gmirror status test s=1 break fi done while mount | grep $mntpoint | grep -q /mirror/; do umount $mntpoint || sleep 5 done while gmirror status test | grep -q SYNCHRONIZING; do sleep 10; done for i in `jot 10`; do gmirror stop test && break || sleep 30 done [ $i -eq 10 ] && s=3 gmirror destroy test 2>/dev/null [ $unload ] && gmirror unload mdconfig -d -u $mdstart || s=4 sed "1,/$last/d" < /var/log/messages | tail -20 | grep -m 1 "check-hash" && s=5 exit $s