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 # bug number for skipped test:
21 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
22 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
24 # bug number for SLOW test:
25 # time in minutes: 40"
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
28 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
29 # bug number for slow tests: LU-2887
30 # time in minutes: 32 12.5"
31 [ "$SLOW" = "no" ] && EXCEPT_SLOW+=" 8a 8b"
32 if [ $MDSCOUNT -gt 1 ]; then
33 # bug number for skipped test:
40 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]*
44 TDIR=$DIR/d0.${TESTSUITE}
46 $LFS setstripe $TDIR -i 0 -c 1
50 zconf_umount $(hostname) $MOUNT -f
51 # needs to run during initial client->OST connection
52 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
53 do_facet ost1 "lctl set_param fail_loc=0x80000211"
54 zconf_mount $(hostname) $MOUNT && $LFS df $MOUNT || error "mount fail"
56 run_test 0a "target handle mismatch (bug 5317)"
60 cp /etc/profile $TDIR/$tfile
62 diff /etc/profile $TDIR/$tfile
65 run_test 0b "empty replay"
68 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
70 $CHECKSTAT -t file $TDIR/$tfile || error "check for file failed"
76 for i in $(seq 10); do
77 echo "tag-$i" > $TDIR/$tfile-$i ||
78 error "create $TDIR/$tfile-$i failed"
81 for i in $(seq 10); do
82 grep -q "tag-$i" $TDIR/$tfile-$i ||
83 error "grep $TDIR/$tfile-$i failed"
87 run_test 2 "|x| 10 open(O_CREAT)s"
90 verify=$ROOT/tmp/verify-$$
91 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
95 wait $ddpid || error "wait for dd failed"
96 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
97 rm -f $verify $TDIR/$tfile
99 run_test 3 "Fail OST during write, with verification"
102 verify=$ROOT/tmp/verify-$$
103 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
104 # invalidate cache, so that we're reading over the wire
106 cmp $verify $TDIR/$tfile &
109 wait $cmppid || error "wait on cmp failed"
110 rm -f $verify $TDIR/$tfile
112 run_test 4 "Fail OST during read, with verification"
117 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
120 echo "+ iozone $args"
121 iozone $args > $tmppipe &
125 echo "tmppipe=$tmppipe"
128 # iozone exit code is 0 even if iozone is not completed
129 # need to check iozone output on "complete"
130 local iozonelog=$TMP/${TESTSUITE}.iozone.log
132 cat $tmppipe | while read line ; do
134 echo "$line" >>$iozonelog
140 if ! $(tail -1 $iozonelog | grep -q complete); then
150 if [ -z "$(which iozone 2> /dev/null)" ]; then
151 skip_env "iozone missing"
155 # striping is -c 1, get min of available
156 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail |
158 local size=$(( minavail * 3/4 ))
159 local GB=1048576 # 1048576KB == 1GB
161 if (( size > GB )); then
164 # no random I/O (-i 2) as it's very slow with ZFS
165 local iozone_opts="-i 0 -i 1 -+d -r 4 -s $size -f $TDIR/$tfile"
167 iozone_bg $iozone_opts &
170 echo iozone bg pid=$pid
175 wait $pid || error "wait on iozone failed"
179 wait_delete_completed_mds
180 [ $rc -eq 0 ] || error "iozone failed"
183 run_test 5 "Fail OST during iozone"
186 calc_osc_kbytes kbytesfree
190 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
193 sync && sleep 5 && sync # wait for delete thread
195 # wait till space is returned, following
196 # (( $before > $after_dd)) test counting on that
197 wait_mds_ost_sync || error "first wait_mds_ost_sync failed"
198 wait_destroy_complete || error "first wait_destroy_complete failed"
201 local before=$(kbytesfree)
202 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
203 $LFS getstripe $f || error "$LFS getstripe $f failed"
204 local stripe_index=$(lfs getstripe -i $f)
207 sleep 2 # ensure we have a fresh statfs
210 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
211 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
213 # retry till statfs returns useful results
214 local after_dd=$(kbytesfree)
216 while (( $before <= $after_dd && $i < 20 )); do
220 after_dd=$(kbytesfree)
223 log "before_free: $before after_dd_free: $after_dd took $i seconds"
224 (( $before > $after_dd )) ||
225 error "free grew after dd: before:$before after_dd:$after_dd"
228 fail ost$((stripe_index + 1))
229 wait_recovery_complete ost$((stripe_index + 1)) ||
230 error "OST$((stripe_index + 1)) recovery not completed"
231 $CHECKSTAT -t file $f && return 2 || true
233 # let the delete happen
234 wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
235 wait_delete_completed || error "second wait_delete_completed failed"
236 local after=$(kbytesfree)
237 log "free_before: $before free_after: $after"
238 (( $before <= $after + $(fs_log_size) )) ||
239 error "$before > $after + logsize $(fs_log_size)"
241 run_test 6 "Fail OST before obd_destroy"
245 sync && sleep 5 && sync # wait for delete thread
247 # wait till space is returned, following
248 # (( $before > $after_dd)) test counting on that
249 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
250 wait_destroy_complete || error "wait_destroy_complete failed"
252 local before=$(kbytesfree)
253 dd if=/dev/urandom bs=4096 count=1280 of=$f ||
254 error "dd to file failed: $?"
257 local after_dd=$(kbytesfree)
259 while (( $before <= $after_dd && $i < 10 )); do
263 after_dd=$(kbytesfree)
266 log "before: $before after_dd: $after_dd took $i seconds"
267 (( $before > $after_dd )) ||
268 error "space grew after dd: before:$before after_dd:$after_dd"
272 wait_recovery_complete ost1 || error "OST recovery not done"
273 $CHECKSTAT -t file $f && return 2 || true
275 # let the delete happen
276 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
277 wait_delete_completed || error "wait_delete_completed failed"
278 local after=$(kbytesfree)
279 log "before: $before after: $after"
280 (( $before <= $after + $(fs_log_size) )) ||
281 error "$before > $after + logsize $(fs_log_size)"
283 run_test 7 "Fail OST before obd_destroy"
286 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
287 { skip "Need MDS version at least 2.3.0"; return; }
288 verify=$ROOT/tmp/verify-$$
289 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
290 error "Create verify file failed"
291 #define OBD_FAIL_OST_DQACQ_NET 0x230
292 do_facet ost1 "lctl set_param fail_loc=0x230"
293 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
295 sleep $TIMEOUT # wait for the io to become redo io
296 if ! ps -p $ddpid > /dev/null 2>&1; then
297 error "redo io finished incorrectly"
299 do_facet ost1 "lctl set_param fail_loc=0"
302 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
303 rm -f $verify $TDIR/$tfile
304 message=$(dmesg | grep "redo for recoverable error -115")
305 [ -z "$message" ] || error "redo error messages found in dmesg"
307 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
310 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
311 { skip "Need MDS version at least 2.3.0"; return; }
312 verify=$ROOT/tmp/verify-$$
313 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
314 error "Create verify file failed"
315 #define OBD_FAIL_OST_DQACQ_NET 0x230
316 do_facet ost1 "lctl set_param fail_loc=0x230"
317 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
319 sleep $TIMEOUT # wait for the io to become redo io
321 do_facet ost1 "lctl set_param fail_loc=0"
322 wait $ddpid || error "dd did not complete"
324 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
325 rm -f $verify $TDIR/$tfile
327 run_test 8b "Verify redo io: redo io should success after recovery"
330 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
331 { skip "Need MDS version at least 2.3.0"; return; }
332 verify=$ROOT/tmp/verify-$$
333 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
334 error "Create verify file failed"
335 #define OBD_FAIL_OST_DQACQ_NET 0x230
336 do_facet ost1 "lctl set_param fail_loc=0x230"
337 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
339 sleep $TIMEOUT # wait for the io to become redo io
341 # allow recovery to complete
342 sleep $((TIMEOUT + 2))
343 do_facet ost1 "lctl set_param fail_loc=0"
346 cmp $verify $TDIR/$tfile && error "compare files should fail"
347 rm -f $verify $TDIR/$tfile
349 run_test 8c "Verify redo io: redo io should fail after eviction"
352 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
353 { skip "Need MDS version at least 2.3.0"; return; }
354 #define OBD_FAIL_MDS_DQACQ_NET 0x187
355 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
356 # test the non-intent create path
357 mcreate $TDIR/$tfile &
360 if ! ps -p $cpid > /dev/null 2>&1; then
361 error "mknod finished incorrectly"
363 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
364 wait $cpid || error "mcreate did not complete"
365 stat $TDIR/$tfile || error "mknod failed"
369 #define OBD_FAIL_MDS_DQACQ_NET 0x187
370 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
371 # test the intent create path
372 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
375 if ! ps -p $cpid > /dev/null 2>&1; then
376 error "open finished incorrectly"
378 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
379 wait $cpid || error "openfile failed"
380 stat $TDIR/$tfile || error "open failed"
382 run_test 8d "Verify redo creation on -EINPROGRESS"
385 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
386 { skip "Need MDS version at least 2.3.0"; return; }
387 sleep 1 # ensure we have a fresh statfs
388 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
389 do_facet ost1 "lctl set_param fail_loc=0x231"
393 if ! ps -p $dfpid > /dev/null 2>&1; then
394 do_facet ost1 "lctl set_param fail_loc=0"
395 error "df shouldn't have completed!"
398 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
401 [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
402 { skip "Need OST version at least 2.6.54"; return; }
403 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
405 # LU-1573 - Add duplicate write to generate grants
406 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
407 error "First write failed"
410 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
411 error "failed to write"
412 # failover, replay and resend replayed waiting request
413 #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
414 do_facet ost1 $LCTL set_param fail_loc=0x00000714
415 do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
417 do_facet ost1 $LCTL set_param fail_loc=0
418 do_facet ost1 "dmesg | tail -n 100" |
419 sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
423 run_test 9 "Verify that no req deadline happened during recovery"
428 dd if=/dev/zero of=$TDIR/$tfile count=10 || error "dd failed"
430 #define OBD_FAIL_OSC_DELAY_IO 0x414
431 $LCTL set_param fail_val=60 fail_loc=0x414
432 cancel_lru_locks OST0000-osc &
434 facet_failover ost1 || error "failover: $?"
436 #define OBD_FAIL_LDLM_GRANT_CHECK 0x32a
437 $LCTL set_param fail_loc=0x32a
442 run_test 10 "conflicting PW & PR locks on a client"
445 [ $FAILURE_MODE != "HARD" ] &&
446 skip "Test needs FAILURE_MODE HARD" && return 0
447 remote_ost || { skip "need remote OST" && return 0; }
454 mkdir -p $tmp || error "can't create $tmp"
455 mkdir -p $dir || error "can't create $dir"
457 $LFS setstripe -c 1 -i 0 $dir
459 for i in `seq 1 10`; do mkdir $dir/d$i; done
461 #define OBD_FAIL_OST_DELAY_TRANS 0x245
462 do_facet ost1 "$LCTL set_param fail_loc=0x245" ||
463 error "can't set fail_loc"
467 createmany -o $dir/d$i/$(openssl rand -base64 12) 500 &
470 echo "Waiting createmany pids"
473 ls -lR $dir > $tmp/ls_r_out 2>&1&
478 echo "starting wait for ls -l"
480 grep "?\|No such file or directory" $tmp/ls_r_out &&
481 error "Found file without object on OST"
485 run_test 12 "check stat after OST failover"
488 check_and_cleanup_lustre