Path: blob/main/tests/sys/geom/class/mirror/9_test.sh
39635 views
#!/bin/sh12# Regression test for r306743.34. `dirname $0`/conf.sh56echo 1..178ddbs=20489m1=`mktemp $base.XXXXXX` || exit 110m2=`mktemp $base.XXXXXX` || exit 111m3=`mktemp $base.XXXXXX` || exit 11213dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&114dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&115dd if=/dev/zero of=$m3 bs=$ddbs count=1024 >/dev/null 2>&11617attach_md us0 -t vnode -f $m1 || exit 118attach_md us1 -t vnode -f $m2 || exit 119attach_md us2 -t vnode -f $m3 || exit 12021gmirror label $name /dev/$us0 /dev/$us1 || exit 122devwait2324# Break one of the mirrors by forcing a single metadata write error.25# When dd closes the mirror provider, gmirror will attempt to mark the mirrors26# clean, and will kick one of the mirrors out upon hitting the error.27sysctl debug.fail_point.g_mirror_metadata_write="1*return(5)[pid $(gmirror_worker_pid)]" || exit 128dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&129sysctl debug.fail_point.g_mirror_metadata_write='off' || exit 13031# Replace the broken mirror, and then stop the gmirror.32gmirror forget $name || exit 133gmirror insert $name /dev/$us2 || exit 134syncwait35gmirror stop $name || exit 13637# Restart the gmirror on the original two mirrors. One of them is broken,38# so we should end up with a degraded gmirror.39gmirror activate $name /dev/$us0 /dev/$us1 || exit 140devwait41dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&14243# Re-add the replacement mirror and verify the two mirrors are synchronized.44# Destroy the gmirror first so that the mirror metadata is wiped; otherwise45# the metadata blocks will fail the comparison. It would be nice to do this46# with a "gmirror verify" command instead.47gmirror activate $name /dev/$us2 || exit 148syncwait49gmirror destroy $name || exit 150if cmp -s $m1 $m3; then51echo "ok 1"52else53echo "not ok 1"54fi5556rm -f $m1 $m2 $m3575859