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 # no random I/O (-i 2) as it's very slow with ZFS
161 local iozone_opts="-i 0 -i 1 -+d -r 4 -s $size -f $TDIR/$tfile"
163 iozone_bg $iozone_opts &
166 echo iozone bg pid=$pid
171 wait $pid || error "wait on iozone failed"
175 wait_delete_completed_mds
176 [ $rc -eq 0 ] || error "iozone failed"
179 run_test 5 "Fail OST during iozone"
182 calc_osc_kbytes kbytesfree
186 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
189 sync && sleep 5 && sync # wait for delete thread
191 # wait till space is returned, following
192 # (( $before > $after_dd)) test counting on that
193 wait_mds_ost_sync || error "first wait_mds_ost_sync failed"
194 wait_destroy_complete || error "first wait_destroy_complete failed"
196 local before=$(kbytesfree)
197 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd failed"
198 $GETSTRIPE $f || error "$GETSTRIPE $f failed"
199 local stripe_index=$(lfs getstripe -i $f)
202 sleep 2 # ensure we have a fresh statfs
205 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
206 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
208 # retry till statfs returns useful results
209 local after_dd=$(kbytesfree)
211 while (( $before <= $after_dd && $i < 20 )); do
215 after_dd=$(kbytesfree)
218 log "before: $before after_dd: $after_dd took $i seconds"
219 (( $before > $after_dd )) ||
220 error "space grew after dd: before:$before after_dd:$after_dd"
222 fail ost$((stripe_index + 1))
223 wait_recovery_complete ost$((stripe_index + 1)) ||
224 error "OST$((stripe_index + 1)) recovery not completed"
225 $CHECKSTAT -t file $f && return 2 || true
227 # let the delete happen
228 wait_mds_ost_sync || error "second wait_mds_ost_sync failed"
229 wait_delete_completed || error "second wait_delete_completed failed"
230 local after=$(kbytesfree)
231 log "before: $before after: $after"
232 (( $before <= $after + $(fs_log_size) )) ||
233 error "$before > $after + logsize $(fs_log_size)"
235 run_test 6 "Fail OST before obd_destroy"
239 sync && sleep 5 && sync # wait for delete thread
241 # wait till space is returned, following
242 # (( $before > $after_dd)) test counting on that
243 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
244 wait_destroy_complete || error "wait_destroy_complete failed"
246 local before=$(kbytesfree)
247 dd if=/dev/urandom bs=4096 count=1280 of=$f ||
248 error "dd to file failed: $?"
251 local after_dd=$(kbytesfree)
253 while (( $before <= $after_dd && $i < 10 )); do
257 after_dd=$(kbytesfree)
260 log "before: $before after_dd: $after_dd took $i seconds"
261 (( $before > $after_dd )) ||
262 error "space grew after dd: before:$before after_dd:$after_dd"
266 wait_recovery_complete ost1 || error "OST recovery not done"
267 $CHECKSTAT -t file $f && return 2 || true
269 # let the delete happen
270 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
271 wait_delete_completed || error "wait_delete_completed failed"
272 local after=$(kbytesfree)
273 log "before: $before after: $after"
274 (( $before <= $after + $(fs_log_size) )) ||
275 error "$before > $after + logsize $(fs_log_size)"
277 run_test 7 "Fail OST before obd_destroy"
280 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
281 { skip "Need MDS version at least 2.3.0"; return; }
282 verify=$ROOT/tmp/verify-$$
283 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
284 error "Create verify file failed"
285 #define OBD_FAIL_OST_DQACQ_NET 0x230
286 do_facet ost1 "lctl set_param fail_loc=0x230"
287 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
289 sleep $TIMEOUT # wait for the io to become redo io
290 if ! ps -p $ddpid > /dev/null 2>&1; then
291 error "redo io finished incorrectly"
293 do_facet ost1 "lctl set_param fail_loc=0"
296 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
297 rm -f $verify $TDIR/$tfile
298 message=$(dmesg | grep "redo for recoverable error -115")
299 [ -z "$message" ] || error "redo error messages found in dmesg"
301 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
304 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
305 { skip "Need MDS version at least 2.3.0"; return; }
306 verify=$ROOT/tmp/verify-$$
307 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
308 error "Create verify file failed"
309 #define OBD_FAIL_OST_DQACQ_NET 0x230
310 do_facet ost1 "lctl set_param fail_loc=0x230"
311 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
313 sleep $TIMEOUT # wait for the io to become redo io
315 do_facet ost1 "lctl set_param fail_loc=0"
316 wait $ddpid || error "dd did not complete"
318 cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
319 rm -f $verify $TDIR/$tfile
321 run_test 8b "Verify redo io: redo io should success after recovery"
324 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
325 { skip "Need MDS version at least 2.3.0"; return; }
326 verify=$ROOT/tmp/verify-$$
327 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
328 error "Create verify file failed"
329 #define OBD_FAIL_OST_DQACQ_NET 0x230
330 do_facet ost1 "lctl set_param fail_loc=0x230"
331 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
333 sleep $TIMEOUT # wait for the io to become redo io
335 # allow recovery to complete
336 sleep $((TIMEOUT + 2))
337 do_facet ost1 "lctl set_param fail_loc=0"
340 cmp $verify $TDIR/$tfile && error "compare files should fail"
341 rm -f $verify $TDIR/$tfile
343 run_test 8c "Verify redo io: redo io should fail after eviction"
346 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
347 { skip "Need MDS version at least 2.3.0"; return; }
348 #define OBD_FAIL_MDS_DQACQ_NET 0x187
349 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
350 # test the non-intent create path
351 mcreate $TDIR/$tfile &
354 if ! ps -p $cpid > /dev/null 2>&1; then
355 error "mknod finished incorrectly"
357 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
358 wait $cpid || error "mcreate did not complete"
359 stat $TDIR/$tfile || error "mknod failed"
363 #define OBD_FAIL_MDS_DQACQ_NET 0x187
364 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
365 # test the intent create path
366 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
369 if ! ps -p $cpid > /dev/null 2>&1; then
370 error "open finished incorrectly"
372 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
373 wait $cpid || error "openfile failed"
374 stat $TDIR/$tfile || error "open failed"
376 run_test 8d "Verify redo creation on -EINPROGRESS"
379 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
380 { skip "Need MDS version at least 2.3.0"; return; }
381 sleep 1 # ensure we have a fresh statfs
382 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
383 do_facet ost1 "lctl set_param fail_loc=0x231"
387 if ! ps -p $dfpid > /dev/null 2>&1; then
388 do_facet ost1 "lctl set_param fail_loc=0"
389 error "df shouldn't have completed!"
392 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
395 [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
396 { skip "Need OST version at least 2.6.54"; return; }
397 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
399 # LU-1573 - Add duplicate write to generate grants
400 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
401 error "First write failed"
404 dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
405 error "failed to write"
406 # failover, replay and resend replayed waiting request
407 #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
408 do_facet ost1 $LCTL set_param fail_loc=0x00000714
409 do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
411 do_facet ost1 $LCTL set_param fail_loc=0
412 do_facet ost1 "dmesg | tail -n 100" |
413 sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
417 run_test 9 "Verify that no req deadline happened during recovery"
422 dd if=/dev/zero of=$TDIR/$tfile count=10 || error "dd failed"
424 #define OBD_FAIL_OSC_DELAY_IO 0x414
425 $LCTL set_param fail_val=60 fail_loc=0x414
426 cancel_lru_locks OST0000-osc &
428 facet_failover ost1 || error "failover: $?"
430 #define OBD_FAIL_LDLM_GRANT_CHECK 0x32a
431 $LCTL set_param fail_loc=0x32a
436 run_test 10 "conflicting PW & PR locks on a client"
439 check_and_cleanup_lustre