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 slowed tests: LU-2887
31 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 8a 8b"
36 check_and_setup_lustre
38 rm -rf $DIR/[df][0-9]*
40 TDIR=$DIR/d0.${TESTSUITE}
42 $SETSTRIPE $TDIR -i 0 -c 1
46 zconf_umount $(hostname) $MOUNT -f
47 # needs to run during initial client->OST connection
48 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
49 do_facet ost1 "lctl set_param fail_loc=0x80000211"
50 zconf_mount $(hostname) $MOUNT && $LFS df $MOUNT || error "mount fail"
52 run_test 0a "target handle mismatch (bug 5317)"
56 cp /etc/profile $TDIR/$tfile
58 diff /etc/profile $TDIR/$tfile
61 run_test 0b "empty replay"
64 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
66 $CHECKSTAT -t file $TDIR/$tfile || error "check for file failed"
72 for i in $(seq 10); do
73 echo "tag-$i" > $TDIR/$tfile-$i ||
74 error "create $TDIR/$tfile-$i failed"
77 for i in $(seq 10); do
78 grep -q "tag-$i" $TDIR/$tfile-$i ||
79 error "grep $TDIR/$tfile-$i failed"
83 run_test 2 "|x| 10 open(O_CREAT)s"
86 verify=$ROOT/tmp/verify-$$
87 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
91 wait $ddpid || error "wait for dd failed"
92 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
93 rm -f $verify $TDIR/$tfile
95 run_test 3 "Fail OST during write, with verification"
98 verify=$ROOT/tmp/verify-$$
99 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
100 # invalidate cache, so that we're reading over the wire
102 cmp $verify $TDIR/$tfile &
105 wait $cmppid || error "wait on cmp failed"
106 rm -f $verify $TDIR/$tfile
108 run_test 4 "Fail OST during read, with verification"
113 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
116 echo "+ iozone $args"
117 iozone $args > $tmppipe &
121 echo "tmppipe=$tmppipe"
124 # iozone exit code is 0 even if iozone is not completed
125 # need to check iozone output on "complete"
126 local iozonelog=$TMP/${TESTSUITE}.iozone.log
128 cat $tmppipe | while read line ; do
130 echo "$line" >>$iozonelog
136 if ! $(tail -1 $iozonelog | grep -q complete); then
146 if [ -z "$(which iozone 2> /dev/null)" ]; then
147 skip_env "iozone missing"
151 # striping is -c 1, get min of available
152 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail |
154 local size=$(( minavail * 3/4 ))
155 local GB=1048576 # 1048576KB == 1GB
157 if (( size > GB )); then
160 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
162 iozone_bg $iozone_opts &
165 echo iozone bg pid=$pid
170 wait $pid || error "wait on iozone failed"
174 wait_delete_completed_mds
175 [ $rc -eq 0 ] || error "iozone failed"
178 run_test 5 "Fail OST during iozone"
181 calc_osc_kbytes kbytesfree
185 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
188 sync && sleep 5 && sync # wait for delete thread
190 # wait till space is returned, following
191 # (( $before > $after_dd)) test counting on that
192 wait_mds_ost_sync || error "first wait_mds_ost_sync failed"
193 wait_destroy_complete || error "first wait_destroy_complete failed"
195 local before=$(kbytesfree)
196 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
197 $GETSTRIPE $f || error "$GETSTRIPE $f failed"
198 local stripe_index=$(lfs getstripe -i $f)
201 sleep 2 # ensure we have a fresh statfs
204 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
205 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
207 # retry till statfs returns useful results
208 local after_dd=$(kbytesfree)
210 while (( $before <= $after_dd && $i < 20 )); do
214 after_dd=$(kbytesfree)
217 log "before: $before after_dd: $after_dd took $i seconds"
218 (( $before > $after_dd )) ||
219 error "space grew after dd: before:$before after_dd:$after_dd"
221 fail ost$((stripe_index + 1))
222 wait_recovery_complete ost$((stripe_index + 1)) ||
223 error "OST$((stripe_index + 1)) recovery not completed"
224 $CHECKSTAT -t file $f && return 2 || true
226 # let the delete happen
227 wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
228 wait_delete_completed || error "second wait_delete_completed failed"
229 local after=$(kbytesfree)
230 log "before: $before after: $after"
231 (( $before <= $after + $(fs_log_size) )) ||
232 error "$before > $after + logsize $(fs_log_size)"
234 run_test 6 "Fail OST before obd_destroy"
238 sync && sleep 5 && sync # wait for delete thread
240 # wait till space is returned, following
241 # (( $before > $after_dd)) test counting on that
242 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
243 wait_destroy_complete || error "wait_destroy_complete failed"
245 local before=$(kbytesfree)
246 dd if=/dev/urandom bs=4096 count=1280 of=$f ||
247 error "dd to file failed: $?"
250 local after_dd=$(kbytesfree)
252 while (( $before <= $after_dd && $i < 10 )); do
256 after_dd=$(kbytesfree)
259 log "before: $before after_dd: $after_dd took $i seconds"
260 (( $before > $after_dd )) ||
261 error "space grew after dd: before:$before after_dd:$after_dd"
265 wait_recovery_complete ost1 || error "OST recovery not done"
266 $CHECKSTAT -t file $f && return 2 || true
268 # let the delete happen
269 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
270 wait_delete_completed || error "wait_delete_completed failed"
271 local after=$(kbytesfree)
272 log "before: $before after: $after"
273 (( $before <= $after + $(fs_log_size) )) ||
274 error "$before > $after + logsize $(fs_log_size)"
276 run_test 7 "Fail OST before obd_destroy"
279 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
280 { skip "Need MDS version at least 2.3.0"; return; }
281 verify=$ROOT/tmp/verify-$$
282 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
283 error "Create verify file failed"
284 #define OBD_FAIL_OST_DQACQ_NET 0x230
285 do_facet ost1 "lctl set_param fail_loc=0x230"
286 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
288 sleep $TIMEOUT # wait for the io to become redo io
289 if ! ps -p $ddpid > /dev/null 2>&1; then
290 error "redo io finished incorrectly"
292 do_facet ost1 "lctl set_param fail_loc=0"
295 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
296 rm -f $verify $TDIR/$tfile
297 message=$(dmesg | grep "redo for recoverable error -115")
298 [ -z "$message" ] || error "redo error messages found in dmesg"
300 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
303 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
304 { skip "Need MDS version at least 2.3.0"; return; }
305 verify=$ROOT/tmp/verify-$$
306 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
307 error "Create verify file failed"
308 #define OBD_FAIL_OST_DQACQ_NET 0x230
309 do_facet ost1 "lctl set_param fail_loc=0x230"
310 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
312 sleep $TIMEOUT # wait for the io to become redo io
314 do_facet ost1 "lctl set_param fail_loc=0"
315 wait $ddpid || error "dd did not complete"
317 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
318 rm -f $verify $TDIR/$tfile
320 run_test 8b "Verify redo io: redo io should success after recovery"
323 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
324 { skip "Need MDS version at least 2.3.0"; return; }
325 verify=$ROOT/tmp/verify-$$
326 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
327 error "Create verify file failed"
328 #define OBD_FAIL_OST_DQACQ_NET 0x230
329 do_facet ost1 "lctl set_param fail_loc=0x230"
330 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
332 sleep $TIMEOUT # wait for the io to become redo io
334 # allow recovery to complete
335 sleep $((TIMEOUT + 2))
336 do_facet ost1 "lctl set_param fail_loc=0"
339 cmp $verify $TDIR/$tfile && error "compare files should fail"
340 rm -f $verify $TDIR/$tfile
342 run_test 8c "Verify redo io: redo io should fail after eviction"
345 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
346 { skip "Need MDS version at least 2.3.0"; return; }
347 #define OBD_FAIL_MDS_DQACQ_NET 0x187
348 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
349 # test the non-intent create path
350 mcreate $TDIR/$tfile &
353 if ! ps -p $cpid > /dev/null 2>&1; then
354 error "mknod finished incorrectly"
356 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
357 wait $cpid || error "mcreate did not complete"
358 stat $TDIR/$tfile || error "mknod failed"
362 #define OBD_FAIL_MDS_DQACQ_NET 0x187
363 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
364 # test the intent create path
365 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
368 if ! ps -p $cpid > /dev/null 2>&1; then
369 error "open finished incorrectly"
371 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
372 wait $cpid || error "openfile failed"
373 stat $TDIR/$tfile || error "open failed"
375 run_test 8d "Verify redo creation on -EINPROGRESS"
378 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
379 { skip "Need MDS version at least 2.3.0"; return; }
380 sleep 1 # ensure we have a fresh statfs
381 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
382 do_facet ost1 "lctl set_param fail_loc=0x231"
386 if ! ps -p $dfpid > /dev/null 2>&1; then
387 do_facet ost1 "lctl set_param fail_loc=0"
388 error "df shouldn't have completed!"
391 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
394 [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
395 { skip "Need OST version at least 2.6.54"; return; }
396 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
398 # LU-1573 - Add duplicate write to generate grants
399 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
400 error "First write failed"
403 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
404 error "failed to write"
405 # failover, replay and resend replayed waiting request
406 #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
407 do_facet ost1 $LCTL set_param fail_loc=0x00000714
408 do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
410 do_facet ost1 $LCTL set_param fail_loc=0
411 do_facet ost1 "dmesg | tail -n 100" |
412 sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
416 run_test 9 "Verify that no req deadline happened during recovery"
421 dd if=/dev/zero of=$TDIR/$tfile count=10 || error "dd failed"
423 #define OBD_FAIL_OSC_DELAY_IO 0x414
424 $LCTL set_param fail_val=60 fail_loc=0x414
425 cancel_lru_locks OST0000-osc &
427 facet_failover ost1 || error "failover: $?"
429 #define OBD_FAIL_LDLM_GRANT_CHECK 0x32a
430 $LCTL set_param fail_loc=0x32a
435 run_test 10 "conflicting PW & PR locks on a client"
438 check_and_cleanup_lustre