5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 # While we do not use OSTCOUNT=1 setup anymore,
14 # ost1failover_HOST is used
15 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
16 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
18 require_dsh_ost || exit 0
20 # Tests that fail on uml
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
26 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
29 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
33 check_and_setup_lustre
35 rm -rf $DIR/[df][0-9]*
37 TDIR=$DIR/d0.${TESTSUITE}
39 $LFS setstripe $TDIR -i 0 -c 1
43 zconf_umount `hostname` $MOUNT -f
44 # needs to run during initial client->OST connection
45 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
46 do_facet ost1 "lctl set_param fail_loc=0x80000211"
47 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
49 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
53 cp /etc/profile $TDIR/$tfile
55 diff /etc/profile $TDIR/$tfile
58 run_test 0b "empty replay"
61 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
63 $CHECKSTAT -t file $TDIR/$tfile || return 1
70 echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
74 grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
78 run_test 2 "|x| 10 open(O_CREAT)s"
81 verify=$ROOT/tmp/verify-$$
82 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
86 wait $ddpid || return 1
87 cmp $verify $TDIR/$tfile || return 2
88 rm -f $verify $TDIR/$tfile
90 run_test 3 "Fail OST during write, with verification"
93 verify=$ROOT/tmp/verify-$$
94 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
95 # invalidate cache, so that we're reading over the wire
97 cmp $verify $TDIR/$tfile &
100 wait $cmppid || return 1
101 rm -f $verify $TDIR/$tfile
103 run_test 4 "Fail OST during read, with verification"
108 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
111 echo "+ iozone $args"
112 iozone $args > $tmppipe &
116 echo "tmppipe=$tmppipe"
119 # iozone exit code is 0 even if iozone is not completed
120 # need to check iozone output on "complete"
121 local iozonelog=$TMP/${TESTSUITE}.iozone.log
123 cat $tmppipe | while read line ; do
125 echo "$line" >>$iozonelog
131 if ! $(tail -1 $iozonelog | grep -q complete); then
141 [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
143 # striping is -c 1, get min of available
144 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
145 local size=$(( minavail * 3/4 ))
146 local GB=1048576 # 1048576KB == 1GB
148 if (( size > GB )); then
151 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
153 iozone_bg $iozone_opts &
156 echo iozone bg pid=$pid
165 [ $rc -eq 0 ] || error "iozone failed"
168 run_test 5 "Fail OST during iozone"
171 calc_osc_kbytes kbytesfree
175 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
179 sync && sleep 2 && sync # wait for delete thread
181 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
183 get_stripe_info client $f
186 sleep 2 # ensure we have a fresh statfs
188 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
189 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
190 after_dd=`kbytesfree`
191 log "before: $before after_dd: $after_dd"
192 (( $before > $after_dd )) || return 1
194 fail ost$((stripe_index + 1))
195 wait_recovery_complete ost$((stripe_index + 1)) || error "OST recovery not done"
196 $CHECKSTAT -t file $f && return 2 || true
198 # let the delete happen
199 wait_mds_ost_sync || return 4
200 wait_destroy_complete || return 5
202 log "before: $before after: $after"
203 (( $before <= $after + 40 )) || return 3 # take OST logs into account
205 run_test 6 "Fail OST before obd_destroy"
210 sync && sleep 5 && sync # wait for delete thread
212 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
214 sleep 2 # ensure we have a fresh statfs
216 after_dd=`kbytesfree`
217 log "before: $before after_dd: $after_dd"
218 (( $before > $after_dd )) || return 1
222 wait_recovery_complete ost1 || error "OST recovery not done"
223 $CHECKSTAT -t file $f && return 2 || true
225 # let the delete happen
226 wait_mds_ost_sync || return 4
227 wait_destroy_complete || return 5
229 log "before: $before after: $after"
230 (( $before <= $after + 40 )) || return 3 # take OST logs into account
232 run_test 7 "Fail OST before obd_destroy"
235 [ -z "$(lctl get_param -n osc.${FSNAME}-*.connect_flags|grep einprogress)" \
236 ] && skip_env "OSTs don't support EINPROGRESS" && return
237 verify=$ROOT/tmp/verify-$$
238 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
239 error "Create verify file failed"
240 #define OBD_FAIL_OST_DQACQ_NET 0x230
241 do_facet ost1 "lctl set_param fail_loc=0x230"
242 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
244 sleep $TIMEOUT # wait for the io to become redo io
245 if ! ps -p $ddpid > /dev/null 2>&1; then
246 error "redo io finished incorrectly"
249 do_facet ost1 "lctl set_param fail_loc=0"
252 cmp $verify $TDIR/$tfile || return 2
253 rm -f $verify $TDIR/$tfile
254 message=`dmesg | grep "redo for recoverable error -115"`
255 [ -z "$message" ] || error "redo error messages found in dmesg"
257 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
260 [ -z "$(lctl get_param -n osc.${FSNAME}-*.connect_flags|grep einprogress)" \
261 ] && skip_env "OSTs don't support EINPROGRESS" && return
262 verify=$ROOT/tmp/verify-$$
263 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
264 error "Create verify file failed"
265 #define OBD_FAIL_OST_DQACQ_NET 0x230
266 do_facet ost1 "lctl set_param fail_loc=0x230"
267 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
269 sleep $TIMEOUT # wait for the io to become redo io
271 do_facet ost1 "lctl set_param fail_loc=0"
272 wait $ddpid || return 1
274 cmp $verify $TDIR/$tfile || return 2
275 rm -f $verify $TDIR/$tfile
277 run_test 8b "Verify redo io: redo io should success after recovery"
280 [ -z "$(lctl get_param -n osc.${FSNAME}-*.connect_flags|grep einprogress)" \
281 ] && skip_env "OSTs don't support EINPROGRESS" && return
282 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
283 { skip "Need MDS version at least 2.3.0"; return; }
284 verify=$ROOT/tmp/verify-$$
285 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
286 error "Create verify file failed"
287 #define OBD_FAIL_OST_DQACQ_NET 0x230
288 do_facet ost1 "lctl set_param fail_loc=0x230"
289 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
291 sleep $TIMEOUT # wait for the io to become redo io
293 # allow recovery to complete
294 sleep $((TIMEOUT + 2))
295 do_facet ost1 "lctl set_param fail_loc=0"
298 cmp $verify $TDIR/$tfile && return 2
299 rm -f $verify $TDIR/$tfile
301 run_test 8c "Verify redo io: redo io should fail after eviction"
304 [ -z "$(lctl get_param -n mdc.${FSNAME}-*.connect_flags|grep einprogress)" \
305 ] && skip_env "MDT doesn't support EINPROGRESS" && return
306 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
307 { skip "Need MDS version at least 2.3.0"; return; }
308 #define OBD_FAIL_MDS_DQACQ_NET 0x187
309 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
310 # test the non-intent create path
311 mcreate $TDIR/$tfile &
314 if ! ps -p $cpid > /dev/null 2>&1; then
315 error "mknod finished incorrectly"
318 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
319 wait $cpid || return 2
320 stat $TDIR/$tfile || error "mknod failed"
324 #define OBD_FAIL_MDS_DQACQ_NET 0x187
325 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
326 # test the intent create path
327 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
330 if ! ps -p $cpid > /dev/null 2>&1; then
331 error "open finished incorrectly"
334 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
335 wait $cpid || return 4
336 stat $TDIR/$tfile || error "open failed"
338 run_test 8d "Verify redo creation on -EINPROGRESS"
341 [ -z "$(lctl get_param -n osc.${FSNAME}-*.connect_flags|grep einprogress)" \
342 ] && skip_env "OSTs don't support EINPROGRESS" && return
343 sleep 1 # ensure we have a fresh statfs
344 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
345 do_facet ost1 "lctl set_param fail_loc=0x231"
349 if ! ps -p $dfpid > /dev/null 2>&1; then
350 do_facet ost1 "lctl set_param fail_loc=0"
351 error "df shouldn't have completed!"
354 do_facet ost1 "lctl set_param fail_loc=0"
356 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
358 complete $(basename $0) $SECONDS
359 check_and_cleanup_lustre