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"
200 local before=$(kbytesfree)
201 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
202 $LFS getstripe $f || error "$LFS getstripe $f failed"
203 local stripe_index=$(lfs getstripe -i $f)
206 sleep 2 # ensure we have a fresh statfs
209 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
210 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
212 # retry till statfs returns useful results
213 local after_dd=$(kbytesfree)
215 while (( $before <= $after_dd && $i < 20 )); do
219 after_dd=$(kbytesfree)
222 log "before: $before after_dd: $after_dd took $i seconds"
223 (( $before > $after_dd )) ||
224 error "space grew after dd: before:$before after_dd:$after_dd"
226 fail ost$((stripe_index + 1))
227 wait_recovery_complete ost$((stripe_index + 1)) ||
228 error "OST$((stripe_index + 1)) recovery not completed"
229 $CHECKSTAT -t file $f && return 2 || true
231 # let the delete happen
232 wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
233 wait_delete_completed || error "second wait_delete_completed failed"
234 local after=$(kbytesfree)
235 log "before: $before after: $after"
236 (( $before <= $after + $(fs_log_size) )) ||
237 error "$before > $after + logsize $(fs_log_size)"
239 run_test 6 "Fail OST before obd_destroy"
243 sync && sleep 5 && sync # wait for delete thread
245 # wait till space is returned, following
246 # (( $before > $after_dd)) test counting on that
247 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
248 wait_destroy_complete || error "wait_destroy_complete failed"
250 local before=$(kbytesfree)
251 dd if=/dev/urandom bs=4096 count=1280 of=$f ||
252 error "dd to file failed: $?"
255 local after_dd=$(kbytesfree)
257 while (( $before <= $after_dd && $i < 10 )); do
261 after_dd=$(kbytesfree)
264 log "before: $before after_dd: $after_dd took $i seconds"
265 (( $before > $after_dd )) ||
266 error "space grew after dd: before:$before after_dd:$after_dd"
270 wait_recovery_complete ost1 || error "OST recovery not done"
271 $CHECKSTAT -t file $f && return 2 || true
273 # let the delete happen
274 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
275 wait_delete_completed || error "wait_delete_completed failed"
276 local after=$(kbytesfree)
277 log "before: $before after: $after"
278 (( $before <= $after + $(fs_log_size) )) ||
279 error "$before > $after + logsize $(fs_log_size)"
281 run_test 7 "Fail OST before obd_destroy"
284 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
285 { skip "Need MDS version at least 2.3.0"; return; }
286 verify=$ROOT/tmp/verify-$$
287 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
288 error "Create verify file failed"
289 #define OBD_FAIL_OST_DQACQ_NET 0x230
290 do_facet ost1 "lctl set_param fail_loc=0x230"
291 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
293 sleep $TIMEOUT # wait for the io to become redo io
294 if ! ps -p $ddpid > /dev/null 2>&1; then
295 error "redo io finished incorrectly"
297 do_facet ost1 "lctl set_param fail_loc=0"
300 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
301 rm -f $verify $TDIR/$tfile
302 message=$(dmesg | grep "redo for recoverable error -115")
303 [ -z "$message" ] || error "redo error messages found in dmesg"
305 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
308 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
309 { skip "Need MDS version at least 2.3.0"; return; }
310 verify=$ROOT/tmp/verify-$$
311 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
312 error "Create verify file failed"
313 #define OBD_FAIL_OST_DQACQ_NET 0x230
314 do_facet ost1 "lctl set_param fail_loc=0x230"
315 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
317 sleep $TIMEOUT # wait for the io to become redo io
319 do_facet ost1 "lctl set_param fail_loc=0"
320 wait $ddpid || error "dd did not complete"
322 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
323 rm -f $verify $TDIR/$tfile
325 run_test 8b "Verify redo io: redo io should success after recovery"
328 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
329 { skip "Need MDS version at least 2.3.0"; return; }
330 verify=$ROOT/tmp/verify-$$
331 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
332 error "Create verify file failed"
333 #define OBD_FAIL_OST_DQACQ_NET 0x230
334 do_facet ost1 "lctl set_param fail_loc=0x230"
335 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
337 sleep $TIMEOUT # wait for the io to become redo io
339 # allow recovery to complete
340 sleep $((TIMEOUT + 2))
341 do_facet ost1 "lctl set_param fail_loc=0"
344 cmp $verify $TDIR/$tfile && error "compare files should fail"
345 rm -f $verify $TDIR/$tfile
347 run_test 8c "Verify redo io: redo io should fail after eviction"
350 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
351 { skip "Need MDS version at least 2.3.0"; return; }
352 #define OBD_FAIL_MDS_DQACQ_NET 0x187
353 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
354 # test the non-intent create path
355 mcreate $TDIR/$tfile &
358 if ! ps -p $cpid > /dev/null 2>&1; then
359 error "mknod finished incorrectly"
361 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
362 wait $cpid || error "mcreate did not complete"
363 stat $TDIR/$tfile || error "mknod failed"
367 #define OBD_FAIL_MDS_DQACQ_NET 0x187
368 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
369 # test the intent create path
370 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
373 if ! ps -p $cpid > /dev/null 2>&1; then
374 error "open finished incorrectly"
376 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
377 wait $cpid || error "openfile failed"
378 stat $TDIR/$tfile || error "open failed"
380 run_test 8d "Verify redo creation on -EINPROGRESS"
383 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
384 { skip "Need MDS version at least 2.3.0"; return; }
385 sleep 1 # ensure we have a fresh statfs
386 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
387 do_facet ost1 "lctl set_param fail_loc=0x231"
391 if ! ps -p $dfpid > /dev/null 2>&1; then
392 do_facet ost1 "lctl set_param fail_loc=0"
393 error "df shouldn't have completed!"
396 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
399 [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
400 { skip "Need OST version at least 2.6.54"; return; }
401 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
403 # LU-1573 - Add duplicate write to generate grants
404 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
405 error "First write failed"
408 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
409 error "failed to write"
410 # failover, replay and resend replayed waiting request
411 #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
412 do_facet ost1 $LCTL set_param fail_loc=0x00000714
413 do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
415 do_facet ost1 $LCTL set_param fail_loc=0
416 do_facet ost1 "dmesg | tail -n 100" |
417 sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
421 run_test 9 "Verify that no req deadline happened during recovery"
426 dd if=/dev/zero of=$TDIR/$tfile count=10 || error "dd failed"
428 #define OBD_FAIL_OSC_DELAY_IO 0x414
429 $LCTL set_param fail_val=60 fail_loc=0x414
430 cancel_lru_locks OST0000-osc &
432 facet_failover ost1 || error "failover: $?"
434 #define OBD_FAIL_LDLM_GRANT_CHECK 0x32a
435 $LCTL set_param fail_loc=0x32a
440 run_test 10 "conflicting PW & PR locks on a client"
443 check_and_cleanup_lustre