1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
#!/bin/bash
num=$1
cmd=$2
dev=$3
if [ "$cmd" == "init" ]; then
echo sanlock direct init -s test:0:$dev:0
sanlock direct init -s test:0:$dev:0
for i in `seq 1 $num`; do
off=`expr $i \* 1048576`
echo sanlock direct init -r test:r$i:$dev:$off
sanlock direct init -r test:r$i:$dev:$off
done
elif [ "$cmd" == "start" ]; then
hostid=$4
killpath=$5
echo sanlock client add_lockspace -s test:$hostid:$dev:0
sanlock client add_lockspace -s test:$hostid:$dev:0
for i in `seq 1 $num`; do
off=`expr $i \* 1048576`
echo ./sanlk_client test r$i $dev $off $killpath &
./sanlk_client test r$i $dev $off $killpath &
done
elif [ "$cmd" == "delay" ]; then
sec=$3
pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
sleep 20
kill -s SIGCONT $pid
sleep 1
echo sigstop sanlock pid $pid
kill -s SIGSTOP $pid
echo sleep $sec
sleep $sec
echo sigcont sanlock pid $pid
kill -s SIGCONT $pid
elif [ "$cmd" == "iodelay" ]; then
sec=$4
pid=`cat /run/sanlock/sanlock.pid`
echo sync with daemon renewals
kill -s SIGSTOP $pid
sleep 20
kill -s SIGCONT $pid
sleep 2
echo save linear
rm -f /tmp/client-state.txt
rm -f /tmp/client-linear.txt
rm -f /tmp/client-error.txt
dmsetup table $dev > /tmp/client-linear.txt
sed "s/linear/error/" /tmp/client-linear.txt > /tmp/client-error.txt
echo load error
dmsetup suspend $dev
dmsetup load $dev /tmp/client-error.txt
dmsetup resume $dev
echo sleep $sec
sleep $sec
echo load linear
dmsetup suspend $dev
dmsetup load $dev /tmp/client-linear.txt
dmsetup resume $dev
elif [ "$cmd" == "error" ]; then
echo save linear
rm -f /tmp/client-state.txt
rm -f /tmp/client-linear.txt
rm -f /tmp/client-error.txt
dmsetup table $dev > /tmp/client-linear.txt
sed "s/linear/error/" /tmp/client-linear.txt > /tmp/client-error.txt
echo load error
dmsetup suspend $dev
dmsetup load $dev /tmp/client-error.txt
dmsetup resume $dev
elif [ "$cmd" == "linear" ]; then
echo load linear
dmsetup suspend $dev
dmsetup load $dev /tmp/client-linear.txt
dmsetup resume $dev
elif [ "$cmd" == "resume" ]; then
hostid=$4
echo load linear
dmsetup suspend $dev
dmsetup load $dev /tmp/client-linear.txt
dmsetup resume $dev
echo sanlock client add_lockspace -s test:$hostid:$dev:0
sanlock client add_lockspace -s test:$hostid:$dev:0
while read pid state; do
echo sanlock client acquire -p $pid -r $state
sanlock client acquire -p $pid -r $state
ret=$?
if [ $ret == 0 ]; then
kill -s SIGCONT $pid
else
kill -s SIGKILL $pid
fi
done < /tmp/client-state.txt
else
echo ""
echo "clientn N init DEV"
echo " sanlock direct init -s test:0:DEV:0"
echo " sanlock direct init -r test:rI:DEV:OFF"
echo ""
echo "clientn N start DEV HOSTID KILLPATH"
echo " sanlock client add_lockspace -s test:HOSTID:DEV:0"
echo " starts N ./sanlk_client processes"
echo ""
echo "clientn N delay SEC"
echo " sigstop sanlock daemon"
echo " sleep SEC"
echo " sigcont sanlock daemon"
echo ""
echo "clientn N iodelay DEV SEC"
echo " block i/o to DEV"
echo " sleep SEC"
echo " unblock i/o to DEV"
echo ""
echo "clientn N linear DEV"
echo " unblock i/o to DEV"
echo ""
echo "clientn N error DEV"
echo " blocks i/o to DEV"
echo " causes KILLPATH to run"
echo " causes lockspace to be removed"
echo ""
echo "clientn N resume DEV HOSTID"
echo " sanlock client add_lockspace -s test:HOSTID:DEV:0"
echo " reacquires leases for sanlk_client pids paused by"
echo " killpath_pause, based on inquire state saved by killpath"
fi
|