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:
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
28 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
29 # bug number for skipped test: LU-2285
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 3"
31 # bug number for slowed tests: LU-2887
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 8a 8b"
38 check_and_setup_lustre
40 rm -rf $DIR/[df][0-9]*
42 TDIR=$DIR/d0.${TESTSUITE}
44 $SETSTRIPE $TDIR -i 0 -c 1
48 zconf_umount $(hostname) $MOUNT -f
49 # needs to run during initial client->OST connection
50 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
51 do_facet ost1 "lctl set_param fail_loc=0x80000211"
52 zconf_mount $(hostname) $MOUNT && $LFS df $MOUNT || error "mount fail"
54 run_test 0a "target handle mismatch (bug 5317)"
58 cp /etc/profile $TDIR/$tfile
60 diff /etc/profile $TDIR/$tfile
63 run_test 0b "empty replay"
66 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
68 $CHECKSTAT -t file $TDIR/$tfile || error "check for file failed"
74 for i in $(seq 10); do
75 echo "tag-$i" > $TDIR/$tfile-$i ||
76 error "create $TDIR/$tfile-$i failed"
79 for i in $(seq 10); do
80 grep -q "tag-$i" $TDIR/$tfile-$i ||
81 error "grep $TDIR/$tfile-$i failed"
85 run_test 2 "|x| 10 open(O_CREAT)s"
88 verify=$ROOT/tmp/verify-$$
89 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
93 wait $ddpid || error "wait for dd failed"
94 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
95 rm -f $verify $TDIR/$tfile
97 run_test 3 "Fail OST during write, with verification"
100 verify=$ROOT/tmp/verify-$$
101 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
102 # invalidate cache, so that we're reading over the wire
104 cmp $verify $TDIR/$tfile &
107 wait $cmppid || error "wait on cmp failed"
108 rm -f $verify $TDIR/$tfile
110 run_test 4 "Fail OST during read, with verification"
115 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
118 echo "+ iozone $args"
119 iozone $args > $tmppipe &
123 echo "tmppipe=$tmppipe"
126 # iozone exit code is 0 even if iozone is not completed
127 # need to check iozone output on "complete"
128 local iozonelog=$TMP/${TESTSUITE}.iozone.log
130 cat $tmppipe | while read line ; do
132 echo "$line" >>$iozonelog
138 if ! $(tail -1 $iozonelog | grep -q complete); then
148 if [ -z "$(which iozone 2> /dev/null)" ]; then
149 skip_env "iozone missing"
153 # striping is -c 1, get min of available
154 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail |
156 local size=$(( minavail * 3/4 ))
157 local GB=1048576 # 1048576KB == 1GB
159 if (( size > GB )); then
162 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
164 iozone_bg $iozone_opts &
167 echo iozone bg pid=$pid
172 wait $pid || error "wait on iozone failed"
176 wait_delete_completed_mds
177 [ $rc -eq 0 ] || error "iozone failed"
180 run_test 5 "Fail OST during iozone"
183 calc_osc_kbytes kbytesfree
187 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
190 sync && sleep 5 && sync # wait for delete thread
192 # wait till space is returned, following
193 # (( $before > $after_dd)) test counting on that
194 wait_mds_ost_sync || error "first wait_mds_ost_sync failed"
195 wait_destroy_complete || error "first wait_destroy_complete failed"
197 local before=$(kbytesfree)
198 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
199 $GETSTRIPE $f || error "$GETSTRIPE $f failed"
200 local stripe_index=$(lfs getstripe -i $f)
203 sleep 2 # ensure we have a fresh statfs
206 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
207 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
209 # retry till statfs returns useful results
210 local after_dd=$(kbytesfree)
212 while (( $before <= $after_dd && $i < 20 )); do
216 after_dd=$(kbytesfree)
219 log "before: $before after_dd: $after_dd took $i seconds"
220 (( $before > $after_dd )) ||
221 error "space grew after dd: before:$before after_dd:$after_dd"
223 fail ost$((stripe_index + 1))
224 wait_recovery_complete ost$((stripe_index + 1)) ||
225 error "OST$((stripe_index + 1)) recovery not completed"
226 $CHECKSTAT -t file $f && return 2 || true
228 # let the delete happen
229 wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
230 wait_delete_completed || error "second wait_delete_completed failed"
231 local after=$(kbytesfree)
232 log "before: $before after: $after"
233 (( $before <= $after + $(fs_log_size) )) ||
234 error "$before > $after + logsize $(fs_log_size)"
236 run_test 6 "Fail OST before obd_destroy"
240 sync && sleep 5 && sync # wait for delete thread
242 # wait till space is returned, following
243 # (( $before > $after_dd)) test counting on that
244 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
245 wait_destroy_complete || error "wait_destroy_complete failed"
247 local before=$(kbytesfree)
248 dd if=/dev/urandom bs=4096 count=1280 of=$f ||
249 error "dd to file failed: $?"
252 local after_dd=$(kbytesfree)
254 while (( $before <= $after_dd && $i < 10 )); do
258 after_dd=$(kbytesfree)
261 log "before: $before after_dd: $after_dd took $i seconds"
262 (( $before > $after_dd )) ||
263 error "space grew after dd: before:$before after_dd:$after_dd"
267 wait_recovery_complete ost1 || error "OST recovery not done"
268 $CHECKSTAT -t file $f && return 2 || true
270 # let the delete happen
271 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
272 wait_delete_completed || error "wait_delete_completed failed"
273 local after=$(kbytesfree)
274 log "before: $before after: $after"
275 (( $before <= $after + $(fs_log_size) )) ||
276 error "$before > $after + logsize $(fs_log_size)"
278 run_test 7 "Fail OST before obd_destroy"
281 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
282 { skip "Need MDS version at least 2.3.0"; return; }
283 verify=$ROOT/tmp/verify-$$
284 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
285 error "Create verify file failed"
286 #define OBD_FAIL_OST_DQACQ_NET 0x230
287 do_facet ost1 "lctl set_param fail_loc=0x230"
288 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
290 sleep $TIMEOUT # wait for the io to become redo io
291 if ! ps -p $ddpid > /dev/null 2>&1; then
292 error "redo io finished incorrectly"
294 do_facet ost1 "lctl set_param fail_loc=0"
297 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
298 rm -f $verify $TDIR/$tfile
299 message=$(dmesg | grep "redo for recoverable error -115")
300 [ -z "$message" ] || error "redo error messages found in dmesg"
302 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
305 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
306 { skip "Need MDS version at least 2.3.0"; return; }
307 verify=$ROOT/tmp/verify-$$
308 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
309 error "Create verify file failed"
310 #define OBD_FAIL_OST_DQACQ_NET 0x230
311 do_facet ost1 "lctl set_param fail_loc=0x230"
312 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
314 sleep $TIMEOUT # wait for the io to become redo io
316 do_facet ost1 "lctl set_param fail_loc=0"
317 wait $ddpid || error "dd did not complete"
319 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
320 rm -f $verify $TDIR/$tfile
322 run_test 8b "Verify redo io: redo io should success after recovery"
325 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
326 { skip "Need MDS version at least 2.3.0"; return; }
327 verify=$ROOT/tmp/verify-$$
328 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
329 error "Create verify file failed"
330 #define OBD_FAIL_OST_DQACQ_NET 0x230
331 do_facet ost1 "lctl set_param fail_loc=0x230"
332 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
334 sleep $TIMEOUT # wait for the io to become redo io
336 # allow recovery to complete
337 sleep $((TIMEOUT + 2))
338 do_facet ost1 "lctl set_param fail_loc=0"
341 cmp $verify $TDIR/$tfile && error "compare files should fail"
342 rm -f $verify $TDIR/$tfile
344 run_test 8c "Verify redo io: redo io should fail after eviction"
347 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
348 { skip "Need MDS version at least 2.3.0"; return; }
349 #define OBD_FAIL_MDS_DQACQ_NET 0x187
350 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
351 # test the non-intent create path
352 mcreate $TDIR/$tfile &
355 if ! ps -p $cpid > /dev/null 2>&1; then
356 error "mknod finished incorrectly"
358 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
359 wait $cpid || error "mcreate did not complete"
360 stat $TDIR/$tfile || error "mknod failed"
364 #define OBD_FAIL_MDS_DQACQ_NET 0x187
365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
366 # test the intent create path
367 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
370 if ! ps -p $cpid > /dev/null 2>&1; then
371 error "open finished incorrectly"
373 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
374 wait $cpid || error "openfile failed"
375 stat $TDIR/$tfile || error "open failed"
377 run_test 8d "Verify redo creation on -EINPROGRESS"
380 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
381 { skip "Need MDS version at least 2.3.0"; return; }
382 sleep 1 # ensure we have a fresh statfs
383 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
384 do_facet ost1 "lctl set_param fail_loc=0x231"
388 if ! ps -p $dfpid > /dev/null 2>&1; then
389 do_facet ost1 "lctl set_param fail_loc=0"
390 error "df shouldn't have completed!"
393 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
396 [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
397 { skip "Need OST version at least 2.6.54"; return; }
398 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
401 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
402 error "failed to write"
403 # failover, replay and resend replayed waiting request
404 #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
405 do_facet ost1 $LCTL set_param fail_loc=0x00000714
406 do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
408 do_facet ost1 $LCTL set_param fail_loc=0
409 do_facet ost1 "dmesg | tail -n 100" |
410 sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
414 run_test 9 "Verify that no req deadline happened during recovery"
417 check_and_cleanup_lustre