17
17
# See the file COPYING included with this distribution for more details.
21
FSTYPE="${FSTYPE:-ext3}"
22
DEFAULTMOUNTOPTS='-o _netdev'
23
[ -z "${MOUNTOPTS}" ] && MOUNTOPTS="${DEFAULTMOUNTOPTS}"
24
# to avoid mount looking for fstype
25
MOUNTOPTIONS="${MOUNTOPTIONS} -t ${FSTYPE}"
26
MKFSCMD="${MKFSCMD:-mkfs.${FSTYPE}} ${MKFSOPTS}"
28
BONNIEPARAMS="${BONNIEPARAMS:--r0 -n10:0:0 -s16 -uroot -f -q}"
22
30
trap regress_signal INT QUIT TERM
24
32
printf "\nterminating, restore defaults: "
25
./iscsiadm -m node -r $record -o update \
26
-n node.session.iscsi.ImmediateData -v Yes
27
./iscsiadm -m node -r $record -o update \
28
-n node.session.iscsi.InitialR2T -v No
29
./iscsiadm -m node -r $record -o update \
30
-n node.conn[0].iscsi.HeaderDigest -v None,CRC32C
31
./iscsiadm -m node -r $record -o update \
32
-n node.session.iscsi.FirstBurstLength -v $((256*1024))
33
./iscsiadm -m node -r $record -o update \
34
-n node.session.iscsi.MaxBurstLength -v $((16*1024*1024-1024))
35
./iscsiadm -m node -r $record -o update \
36
-n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $((128*1024))
33
# use the other function to clean up
36
hdrdgst_en="None,CRC32C"
37
datdgst_en="None,CRC32C"
38
c="${iscsiadm} -m node -T $target -p $ipnr -o update"
39
first_burst="$((256*1024))"
40
max_burst="$((16*1024*1024-1024))"
41
max_recv_dlength="$((128*1024))"
44
${iscsiadm} -m node -T $target -p $ipnr --logout 2>/dev/null >/dev/null
41
49
function update_cfg() {
42
./iscsiadm -m node -r $record -u
43
./iscsiadm -m node -r $record -o update \
44
-n node.session.iscsi.ImmediateData -v $imm_data_en
45
./iscsiadm -m node -r $record -o update \
46
-n node.session.iscsi.InitialR2T -v $initial_r2t_en
47
./iscsiadm -m node -r $record -o update \
48
-n node.conn[0].iscsi.HeaderDigest -v $hdrdgst_en
49
./iscsiadm -m node -r $record -o update \
50
-n node.session.iscsi.FirstBurstLength -v $first_burst
51
./iscsiadm -m node -r $record -o update \
52
-n node.session.iscsi.MaxBurstLength -v $max_burst
53
./iscsiadm -m node -r $record -o update \
54
-n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $max_recv_dlength
55
./iscsiadm -m node -r $record -l
50
c="${iscsiadm} -m node -T $target -p $ipnr -o update"
51
$c -n node.session.iscsi.ImmediateData -v $imm_data_en
52
$c -n node.session.iscsi.InitialR2T -v $initial_r2t_en
53
$c -n node.conn[0].iscsi.HeaderDigest -v $hdrdgst_en
54
$c -n node.conn[0].iscsi.DataDigest -v $datdgst_en
55
$c -n node.session.iscsi.FirstBurstLength -v $first_burst
56
$c -n node.session.iscsi.MaxBurstLength -v $max_burst
57
$c -n node.conn[0].iscsi.MaxRecvDataSegmentLength -v $max_recv_dlength
58
$c -n node.session.iscsi.MaxOutstandingR2T -v $max_r2t
58
61
function disktest_run() {
59
62
bsizes="512 1024 2048 4096 8192 16384 32768 65536 131072 1000000"
60
test x$bsize != x && bsizes=$bsize
61
test x$bsize = xbonnie && return 0;
63
test "x$bsize" != x && bsizes=$bsize
64
test "x$bsize" = xbonnie && return 0;
62
65
for bs in $bsizes; do
63
66
echo -n "disktest -T2 -K8 -B$bs -r -ID $device: "
64
if ! disktest -T2 -K8 -B$bs -r -ID $device >/dev/null; then
67
if ! ${disktest} -T2 -K8 -B$bs -r -ID $device >/dev/null; then
69
72
echo -n "disktest -T2 -K8 -B$bs -E16 -w -ID $device: "
70
if ! disktest -T2 -K8 -B$bs -E16 -w -ID $device >/dev/null;then
73
if ! ${disktest} -T2 -K8 -B$bs -E16 -w -ID $device >/dev/null;then
109
109
function bonnie_run() {
110
dir="/tmp/iscsi.bonnie.regression"
110
dir="/tmp/iscsi.bonnie.regression.$record.$RANDOM"
112
111
umount $dir 2>/dev/null >/dev/null
113
112
rm -rf $dir; mkdir $dir
114
113
echo -n "mount $dir: "
115
if ! mount -t ext2 $device"1" $dir; then
114
if ! mount ${MOUNTOPTIONS} $device_partition $dir; then
120
echo -n "bonnie++ -r0 -n10:0:0 -s16 -uroot -f -q: "
119
echo -n "bonnie++ ${BONNIEPARAMS}: "
121
120
pushd $dir >/dev/null
122
if ! $bonnie_dir/bonnie++ -r0 -n10:0:0 -s16 -uroot -f -q 2>/dev/null >/dev/null; then
124
umount $dir 2>/dev/null >/dev/null
121
${bonnie} ${BONNIEPARAMS} 2>/dev/null >/dev/null
129
124
umount $dir 2>/dev/null >/dev/null
126
if [ $rc -ne 0 ]; then
134
134
function fatal() {
135
135
echo "regression.sh: $1"
136
echo "Usage: regression.sh <rec#|-f> <device> [test#[:#]] [bsize]"
136
echo "Usage: regression.sh <targetname|-f> <ipnumber#> <device> [test#[:#]] [bsize]"
140
140
############################ main ###################################
142
test ! -e regression.dat && fatal "can not find regression.dat"
143
test ! -e disktest && fatal "can not find disktest"
144
test ! -e iscsiadm && fatal "can not find iscsiadm"
145
test ! -e bonnie++ && fatal "can not find bonnie++"
146
test x$1 = x && fatal "node record parameter error"
147
test x$2 = x && fatal "SCSI device parameter error"
142
disktest=`which disktest`
143
iscsiadm=`which iscsiadm`
144
bonnie=`which bonnie++`
145
datfile=`dirname $0`"/regression.dat"
146
test ! -e ${datfile} && fatal "can not find regression.dat"
147
test ! -e ${disktest} && fatal "can not find disktest"
148
test ! -e ${iscsiadm} && fatal "can not find iscsiadm"
149
test ! -e ${bonnie} && fatal "can not find bonnie++"
150
test x$1 = x && fatal "target name parameter error"
151
test x$2 = x && fatal "ipnumber parameter error"
152
test x$3 = x && fatal "SCSI device parameter error"
150
154
if test x$1 = "x-f" -o x$1 = "x--format"; then
156
test x$3 != x && begin=$3
157
test x$4 != x && bsize=$4
159
if test x$begin != x; then
160
end=`echo $begin | awk -F: '{print $2}'`
161
begin=`echo $begin | awk -F: '{print $1}'`
167
Open-iSCSI Regression Test Suite is about to start. It is going
168
to use "$device" for its testing. iSCSI session could be re-opened
169
during the tests several times and as the result device name could
170
not match provided device name if some other SCSI activity happened
173
Are you sure you want to continue? [y/n]: "
175
if test x$line = xn -o x$line = xN -o x$line = xno -o x$line = xNO; then
163
device_dir="$(dirname ${device})"
165
case "${device_dir}" in
167
/dev) device_partition="${device}1" ;;
168
# /dev/disk/by-id/scsi-${ID_SERIAL}-part1
169
# where ID_SERIAL is SCSI disk SERIAL from scsi_id
170
/dev/disk/by-id|/dev/disk/by-path) device_partition="${device}-part1" ;;
172
/dev/iscsi/*) device_partition="${device}-part1" ;;
175
if [ -z "${device_partition}" ]; then
176
echo 'Unable to find device name for first partition.' >&2
180
test "x$4" != x && begin="$4"
181
test "x$5" != x && bsize="$5"
183
if test "x$begin" != "x"; then
188
# don't say we didn't warn you
189
if [ -z "${SKIP_WARNING}" ]; then
193
Open-iSCSI Regression Test Suite is about to start. It is going
194
to use "$device" for its testing. iSCSI session could be re-opened
195
during the tests several times and as the result device name could
196
not match provided device name if some other SCSI activity happened
199
Are you sure you want to continue? [y/n]:
202
if test x$line = xn -o x$line = xN -o x$line = xno -o x$line = xNO; then
181
cat regression.dat | while read line; do
209
cat ${datfile} | while read line; do
182
210
if echo $line | grep "^#" >/dev/null; then continue; fi
183
211
if echo $line | grep "^$" >/dev/null; then continue; fi
184
212
if test x$begin != x; then
196
224
if test x$imm_data_en = x; then continue; fi
197
225
initial_r2t_en=`echo $line | awk '{print $2}'`
198
226
hdrdgst_en=`echo $line | awk '{print $3}'`
199
first_burst=`echo $line | awk '{print $4}'`
200
max_burst=`echo $line | awk '{print $5}'`
201
max_recv_dlength=`echo $line | awk '{print $6}'`
202
max_r2t=`echo $line | awk '{print $7}'`
227
datdgst_en=`echo $line | awk '{print $4}'`
228
first_burst=`echo $line | awk '{print $5}'`
229
max_burst=`echo $line | awk '{print $6}'`
230
max_recv_dlength=`echo $line | awk '{print $7}'`
231
max_r2t=`echo $line | awk '{print $8}'`
232
# ensure we are logged out
233
${iscsiadm} -m node -T $target -p $ipnr --logout 2>/dev/null >/dev/null
234
# set parameters for next run
204
236
echo "================== TEST #$i BEGIN ===================="
205
echo "imm_data_en = $imm_data_en"
206
echo "initial_r2t_en = $initial_r2t_en"
207
echo "hdrdgst_en = $hdrdgst_en"
208
echo "first_burst = $first_burst"
209
echo "max_burst = $max_burst"
210
echo "max_recv_dlength = $max_recv_dlength"
211
echo "max_r2t = $max_r2t"
237
echo "ImmediateData = $imm_data_en"
238
echo "InitialR2T = $initial_r2t_en"
239
echo "HeaderDigest = $hdrdgst_en"
240
echo "DataDigest = $datdgst_en"
241
echo "FirstBurstLength = $first_burst"
242
echo "MaxBurstLength = $max_burst"
243
echo "MaxRecvDataSegmentLength = $max_recv_dlength"
244
echo "MaxOutstandingR2T = $max_r2t"
246
# catch errors on this
247
if ! ${iscsiadm} -m node -T $target -p $ipnr --login; then break; fi
248
while [ ! -e $device ] ; do sleep 1 ; done
212
249
if ! disktest_run; then break; fi
213
250
if ! fdisk_run; then break; fi
214
251
if ! mkfs_run; then break; fi