5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
12 # While we do not use OSTCOUNT=1 setup anymore,
13 # ost1failover_HOST is used
14 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
15 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
17 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
19 # Tests that fail on uml
20 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
21 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
25 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
28 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
32 check_and_setup_lustre
34 rm -rf $DIR/[df][0-9]*
36 TDIR=$DIR/d0.${TESTSUITE}
38 $LFS setstripe $TDIR -i 0 -c 1
42 zconf_umount `hostname` $MOUNT -f
43 # needs to run during initial client->OST connection
44 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
45 do_facet ost1 "lctl set_param fail_loc=0x80000211"
46 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
48 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
52 cp /etc/profile $TDIR/$tfile
54 diff /etc/profile $TDIR/$tfile
57 run_test 0b "empty replay"
62 $CHECKSTAT -t file $TDIR/$tfile || return 1
69 echo "tag-$i" > $TDIR/$tfile-$i
73 grep -q "tag-$i" $TDIR/$tfile-$i || error "f2-$i"
77 run_test 2 "|x| 10 open(O_CREAT)s"
80 verify=$ROOT/tmp/verify-$$
81 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
85 wait $ddpid || return 1
86 cmp $verify $TDIR/$tfile || return 2
87 rm -f $verify $TDIR/$tfile
89 run_test 3 "Fail OST during write, with verification"
92 verify=$ROOT/tmp/verify-$$
93 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
94 # invalidate cache, so that we're reading over the wire
96 cmp $verify $TDIR/$tfile &
99 wait $cmppid || return 1
100 rm -f $verify $TDIR/$tfile
102 run_test 4 "Fail OST during read, with verification"
107 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
110 echo "+ iozone $args"
111 iozone $args > $tmppipe &
115 echo "tmppipe=$tmppipe"
118 # iozone exit code is 0 even if iozone is not completed
119 # need to check iozone output on "complete"
120 local iozonelog=$TMP/${TESTSUITE}.iozone.log
122 cat $tmppipe | while read line ; do
124 echo "$line" >>$iozonelog
130 if ! $(tail -1 $iozonelog | grep -q complete); then
140 [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
142 # striping is -c 1, get min of available
143 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
144 local size=$(( minavail * 3/4 ))
145 local GB=1048576 # 1048576KB == 1GB
147 if (( size > GB )); then
150 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
152 iozone_bg $iozone_opts &
155 echo iozone bg pid=$pid
164 [ $rc -eq 0 ] || error "iozone failed"
167 run_test 5 "Fail OST during iozone"
170 calc_osc_kbytes kbytesfree
174 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
178 sync && sleep 2 && sync # wait for delete thread
180 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
182 get_stripe_info client $f
185 sleep 2 # ensure we have a fresh statfs
187 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
188 do_facet mds "lctl set_param fail_loc=0x80000119"
189 after_dd=`kbytesfree`
190 log "before: $before after_dd: $after_dd"
191 (( $before > $after_dd )) || return 1
193 fail ost$((stripe_index + 1))
194 wait_recovery_complete ost$((stripe_index + 1)) || error "OST recovery isn't done"
195 $CHECKSTAT -t file $f && return 2 || true
197 # let the delete happen
198 wait_mds_ost_sync || return 4
199 wait_destroy_complete || return 5
201 log "before: $before after: $after"
202 (( $before <= $after + 40 )) || return 3 # take OST logs into account
204 run_test 6 "Fail OST before obd_destroy"
209 sync && sleep 2 && sync # wait for delete thread
211 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
213 sleep 2 # ensure we have a fresh statfs
215 after_dd=`kbytesfree`
216 log "before: $before after_dd: $after_dd"
217 (( $before > $after_dd )) || return 1
221 wait_recovery_complete ost1 || error "OST recovery isn't done"
222 $CHECKSTAT -t file $f && return 2 || true
224 # let the delete happen
225 wait_mds_ost_sync || return 4
226 wait_destroy_complete || return 5
228 log "before: $before after: $after"
229 (( $before <= $after + 40 )) || return 3 # take OST logs into account
231 run_test 7 "Fail OST before obd_destroy"
233 complete $(basename $0) $SECONDS
234 check_and_cleanup_lustre