6 ALWAYS_EXCEPT="24 52 $RECOVERY_SMALL_EXCEPT"
8 PTLDEBUG=${PTLDEBUG:--1}
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 . $LUSTRE/tests/test-framework.sh
12 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
15 require_dsh_mds || exit 0
17 # also long tests: 19, 21a, 21e, 21f, 23, 27
18 # 1 2.5 2.5 4 4 (min)"
19 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
23 # Allow us to override the setup if we already have a mounted system by
24 # setting SETUP=" " and CLEANUP=" "
26 CLEANUP=${CLEANUP:-""}
28 check_and_setup_lustre
31 rm -rf $DIR/[df][0-9]*
34 drop_request "mcreate $DIR/f1" || return 1
35 drop_reint_reply "mcreate $DIR/f2" || return 2
37 run_test 1 "mcreate: drop req, drop rep"
40 drop_request "tchmod 111 $DIR/f2" || return 1
41 drop_reint_reply "tchmod 666 $DIR/f2" || return 2
43 run_test 2 "chmod: drop req, drop rep"
46 drop_request "statone $DIR/f2" || return 1
47 drop_reply "statone $DIR/f2" || return 2
49 run_test 3 "stat: drop req, drop rep"
51 SAMPLE_NAME=f0.recovery-small.junk
52 SAMPLE_FILE=$TMP/$SAMPLE_NAME
53 # make this big, else test 9 doesn't wait for bulk -- bz 5595
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
57 do_facet client "cp $SAMPLE_FILE $DIR/$SAMPLE_NAME" || return 1
58 drop_request "cat $DIR/$SAMPLE_NAME > /dev/null" || return 2
59 drop_reply "cat $DIR/$SAMPLE_NAME > /dev/null" || return 3
61 run_test 4 "open: drop req, drop rep"
63 RENAMED_AGAIN=$DIR/f0.renamed-again
66 drop_request "mv $DIR/$SAMPLE_NAME $DIR/$tfile-renamed" || return 1
67 drop_reint_reply "mv $DIR/$tfile-renamed $RENAMED_AGAIN" || return 2
68 do_facet client "checkstat -v $RENAMED_AGAIN" || return 3
70 run_test 5 "rename: drop req, drop rep"
72 [ ! -e $RENAMED_AGAIN ] && cp $SAMPLE_FILE $RENAMED_AGAIN
77 drop_request "mlink $RENAMED_AGAIN $LINK1" || return 1
78 drop_reint_reply "mlink $RENAMED_AGAIN $LINK2" || return 2
80 run_test 6 "link: drop req, drop rep"
82 [ ! -e $LINK1 ] && mlink $RENAMED_AGAIN $LINK1
83 [ ! -e $LINK2 ] && mlink $RENAMED_AGAIN $LINK2
85 drop_request "munlink $LINK1" || return 1
86 drop_reint_reply "munlink $LINK2" || return 2
88 run_test 7 "unlink: drop req, drop rep"
92 drop_reint_reply "touch $DIR/$tfile" || return 1
94 run_test 8 "touch: drop rep (bug 1423)"
98 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
100 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
101 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
102 do_facet client "sync"
103 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
105 run_test 9 "pause bulk on OST (bug 1420)"
109 do_facet client mcreate $DIR/$tfile || return 1
110 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
111 # wait for the mds to evict the client
112 #echo "sleep $(($TIMEOUT*2))"
113 #sleep $(($TIMEOUT*2))
114 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
115 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
116 do_facet client "munlink $DIR/$tfile"
118 run_test 10 "finish request on server after client eviction (bug 1521)"
121 # wake up a thread waiting for completion after eviction
123 do_facet client multiop $DIR/$tfile Ow || return 1
124 do_facet client multiop $DIR/$tfile or || return 2
128 do_facet client multiop $DIR/$tfile or || return 3
129 drop_bl_callback multiop $DIR/$tfile Ow || echo "evicted as expected"
131 do_facet client munlink $DIR/$tfile || return 4
133 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
137 $LCTL mark multiop $DIR/$tfile OS_c
138 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
139 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
140 multiop_bg_pause $DIR/$tfile OS_c || return 1
142 #define OBD_FAIL_MDS_CLOSE_NET 0x115
144 echo "waiting for multiop $PID"
145 wait $PID || return 2
146 do_facet client munlink $DIR/$tfile || return 3
148 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
150 # Bug 113, check that readdir lost recv timeout works.
152 mkdir -p $DIR/$tdir || return 1
153 touch $DIR/$tdir/newentry || return
154 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
155 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
156 ls $DIR/$tdir || return 3
157 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
158 rm -rf $DIR/$tdir || return 4
160 run_test 13 "mdc_readpage restart test (bug 1138)"
162 # Bug 113, check that readdir lost send timeout works.
165 touch $DIR/$tdir/newentry
166 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
168 ls $DIR/$tdir || return 1
169 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
171 run_test 14 "mdc_readpage resend test (bug 1138)"
174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
175 touch $DIR/$tfile && return 1
178 run_test 15 "failed open (-ENOMEM)"
180 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
182 lctl set_param -n llite.*.max_read_ahead_mb 0
186 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
190 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
192 do_facet client cp $SAMPLE_FILE $DIR
196 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
197 do_facet ost1 "lctl set_param fail_loc=0x80000504"
199 # OST bulk will time out here, client resends
200 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
201 do_facet ost1 lctl set_param fail_loc=0
202 # give recovery a chance to finish (shouldn't take long)
204 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
207 run_test 16 "timeout bulk put, don't evict client (2732)"
212 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
214 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
215 if at_is_enabled; then
216 at_max_saved=$(at_max_get ost1)
217 at_max_set $TIMEOUT ost1
220 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
221 # OST bulk will time out here, client retries
222 do_facet ost1 lctl set_param fail_loc=0x80000503
223 # need to ensure we send an RPC
224 do_facet client cp $SAMPLE_FILE $DIR/$tfile
227 # with AT, client will wait adaptive_max*factor+net_latency before
228 # expiring the req, hopefully timeout*2 is enough
229 sleep $(($TIMEOUT*2))
231 do_facet ost1 lctl set_param fail_loc=0
232 do_facet client "df $DIR"
233 # expect cmp to succeed, client resent bulk
234 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
235 do_facet client "rm $DIR/$tfile" || return 4
236 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
239 run_test 17 "timeout bulk get, don't evict client (2732)"
242 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
244 do_facet client mkdir -p $DIR/$tdir
248 pgcache_empty || return 1
251 lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
252 get_stripe_info client $f
253 if [ $stripe_index -ne 1 ]; then
255 error "$f: different stripe offset ($stripe_index)" && return
258 do_facet client cp $SAMPLE_FILE $f
260 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
261 $LCTL --device $osc2dev deactivate || return 3
262 # my understanding is that there should be nothing in the page
263 # cache after the client reconnects?
265 pgcache_empty || rc=2
266 $LCTL --device $osc2dev activate
270 run_test 18a "manual ost invalidate clears page cache immediately"
273 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
275 do_facet client mkdir -p $DIR/$tdir
279 pgcache_empty || return 1
281 # shouldn't have to set stripe size of count==1
282 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
283 get_stripe_info client $f
284 if [ $stripe_index -ne 0 ]; then
286 error "$f: different stripe offset ($stripe_index)" && return
289 do_facet client cp $SAMPLE_FILE $f
292 # allow recovery to complete
293 sleep $((TIMEOUT + 2))
294 # my understanding is that there should be nothing in the page
295 # cache after the client reconnects?
297 pgcache_empty || rc=2
301 run_test 18b "eviction and reconnect clears page cache (2766)"
304 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
306 do_facet client mkdir -p $DIR/$tdir
310 pgcache_empty || return 1
312 # shouldn't have to set stripe size of count==1
313 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
314 get_stripe_info client $f
315 if [ $stripe_index -ne 0 ]; then
317 error "$f: different stripe offset ($stripe_index)" && return
320 do_facet client cp $SAMPLE_FILE $f
324 # OBD_FAIL_OST_CONNECT_NET2
325 # lost reply to connect request
326 do_facet ost1 lctl set_param fail_loc=0x80000225
328 df $MOUNT > /dev/null 2>&1
330 # my understanding is that there should be nothing in the page
331 # cache after the client reconnects?
333 pgcache_empty || rc=2
337 run_test 18c "Dropped connect reply after eviction handing (14755)"
341 do_facet client mcreate $f || return 1
342 drop_ldlm_cancel "chmod 0777 $f" || echo "evicted as expected"
344 do_facet client checkstat -v -p 0777 $f || echo evicted
345 # let the client reconnect
347 do_facet client "munlink $f"
349 run_test 19a "test expired_lock_main on mds (2867)"
353 do_facet client multiop $f Ow || return 1
354 do_facet client multiop $f or || return 2
358 do_facet client multiop $f or || return 3
359 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
361 do_facet client munlink $f || return 4
363 run_test 19b "test expired_lock_main on ost (2867)"
365 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
366 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
369 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
370 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
373 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
374 do_facet ost1 lctl set_param fail_loc=0x80000308
375 kill -USR1 $MULTI_PID
378 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
380 run_test 20a "ldlm_handle_enqueue error (should return error)"
382 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
383 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
386 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
388 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
389 do_facet ost1 lctl set_param fail_loc=0x80000308
390 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
391 error "didn't fail open enqueue" || true
393 run_test 20b "ldlm_handle_enqueue error (should return error)"
396 mkdir -p $DIR/$tdir-1
397 mkdir -p $DIR/$tdir-2
398 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
401 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
402 multiop $DIR/$tdir-2/f Oc &
405 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
407 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
408 kill -USR1 $close_pid
410 wait $close_pid || return 1
411 wait $open_pid || return 2
412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
414 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
415 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
419 run_test 21a "drop close request while close and open are both in flight"
422 mkdir -p $DIR/$tdir-1
423 mkdir -p $DIR/$tdir-2
424 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
427 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
428 mcreate $DIR/$tdir-2/f &
431 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
433 kill -USR1 $close_pid
435 wait $close_pid || return 1
436 wait $open_pid || return 3
438 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
439 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
442 run_test 21b "drop open request while close and open are both in flight"
445 mkdir -p $DIR/$tdir-1
446 mkdir -p $DIR/$tdir-2
447 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
450 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
451 mcreate $DIR/$tdir-2/f &
454 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
456 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
457 kill -USR1 $close_pid
459 wait $close_pid || return 1
460 wait $open_pid || return 2
462 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
464 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
465 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
468 run_test 21c "drop both request while close and open are both in flight"
471 mkdir -p $DIR/$tdir-1
472 mkdir -p $DIR/$tdir-2
473 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
476 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
477 multiop $DIR/$tdir-2/f Oc &
479 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
481 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
484 wait $pid || return 1
485 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
487 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
488 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
492 run_test 21d "drop close reply while close and open are both in flight"
495 mkdir -p $DIR/$tdir-1
496 mkdir -p $DIR/$tdir-2
497 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
500 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
501 touch $DIR/$tdir-2/f &
503 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
507 wait $pid || return 1
510 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
511 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
514 run_test 21e "drop open reply while close and open are both in flight"
517 mkdir -p $DIR/$tdir-1
518 mkdir -p $DIR/$tdir-2
519 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
523 touch $DIR/$tdir-2/f &
525 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
527 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
530 wait $pid || return 1
531 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
533 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
534 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
537 run_test 21f "drop both reply while close and open are both in flight"
540 mkdir -p $DIR/$tdir-1
541 mkdir -p $DIR/$tdir-2
542 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
545 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
546 touch $DIR/$tdir-2/f &
548 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
550 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
553 wait $pid || return 1
554 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
556 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
557 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
560 run_test 21g "drop open reply and close request while close and open are both in flight"
563 mkdir -p $DIR/$tdir-1
564 mkdir -p $DIR/$tdir-2
565 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
568 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
569 touch $DIR/$tdir-2/f &
572 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
574 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
577 wait $pid || return 1
578 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
580 wait $touch_pid || return 2
582 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
583 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
586 run_test 21h "drop open request and close reply while close and open are both in flight"
588 # bug 3462 - multiple MDC requests
593 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
598 multiop $f1 msu || return 1
601 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
603 wait $close_pid || return 2
604 rm -rf $f2 || return 4
606 run_test 22 "drop close request and do mknod"
609 multiop_bg_pause $DIR/$tfile O_c || return 1
611 # give a chance for open
615 drop_request "kill -USR1 $pid"
618 wait $pid || return 1
621 run_test 23 "client hang when close a file after mds crash"
623 test_24() { # bug 11710 details correct fsync() behavior
624 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
627 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
629 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
632 kill -USR1 $MULTI_PID
635 lctl set_param fail_loc=0x0
637 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
639 run_test 24 "fsync error (should return error)"
641 wait_client_evicted () {
644 local varsvc=${facet}_svc
646 wait_update $(facet_host $facet) "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" $((exports - 1)) $3
649 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
650 # this test can only run from a client on a separate node.
651 remote_ost || { skip "local OST" && return 0; }
652 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
653 remote_mds || { skip "local MDS" && return 0; }
655 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
656 skip "msg and ost1 are at the same node"
660 check_timeout || return 1
662 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
664 echo starting with $OST_NEXP OST exports
665 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
666 do_facet client lctl set_param fail_loc=0x505
667 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
668 # But if there's a race to start the evictor from various obds,
669 # the loser might have to wait for the next ping.
672 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
674 do_facet client lctl set_param fail_loc=0x0
675 [ $rc -eq 0 ] || error "client not evicted from OST"
677 run_test 26a "evict dead exports"
679 test_26b() { # bug 10140 - evict dead exports by pinger
680 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
682 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
683 skip "msg and ost1 are at the same node"
687 check_timeout || return 1
689 zconf_mount `hostname` $MOUNT2 ||
690 { error "Failed to mount $MOUNT2"; return 2; }
691 sleep 1 # wait connections being established
693 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
694 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
696 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
698 zconf_umount `hostname` $MOUNT2 -f
700 # PING_INTERVAL max(obd_timeout / 4, 1U)
701 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
703 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
704 # But if there's a race to start the evictor from various obds,
705 # the loser might have to wait for the next ping.
706 # = 9 * PING_INTERVAL + PING_INTERVAL
707 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
708 # let's wait $((TIMEOUT * 3)) # bug 19887
710 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
711 error "Client was not evicted by ost" rc=1
712 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
713 error "Client was not evicted by mds"
715 run_test 26b "evict dead exports"
719 writemany -q -a $DIR/$tdir/$tfile 0 5 &
722 local save_FAILURE_MODE=$FAILURE_MODE
724 facet_failover $SINGLEMDS
725 #define OBD_FAIL_OSC_SHUTDOWN 0x407
726 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
727 # need to wait for reconnect
728 echo waiting for fail_loc
729 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
730 facet_failover $SINGLEMDS
732 kill -USR1 $CLIENT_PID
735 FAILURE_MODE=$save_FAILURE_MODE
737 run_test 27 "fail LOV while using OSC's"
739 test_28() { # bug 6086 - error adding new clients
740 do_facet client mcreate $DIR/$tfile || return 1
741 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
742 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
743 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
744 # fail once (evicted), reconnect fail (fail_loc), ok
745 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
747 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
749 run_test 28 "handle error adding new clients (bug 6086)"
751 test_29a() { # bug 22273 - error adding new clients
752 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
753 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
754 # fail abort so client will be new again
755 fail_abort $SINGLEMDS
756 client_up || error "reconnect failed"
759 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
761 test_29b() { # bug 22273 - error adding new clients
762 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
763 do_facet ost1 "lctl set_param fail_loc=0x80000711"
764 # fail abort so client will be new again
766 client_up || error "reconnect failed"
769 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
773 # put a load of file creates/writes/deletes
774 writemany -q $DIR/$tdir/$tfile 0 5 &
776 echo writemany pid $CLIENT_PID
780 # wait for client to reconnect to MDS
785 # client process should see no problems even though MDS went down
787 kill -USR1 $CLIENT_PID
790 echo writemany returned $rc
791 #these may fail because of eviction due to slow AST response.
792 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
794 run_test 50 "failover MDS under load"
797 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
798 do_facet ost1 lctl set_param fail_loc=0x00001310
801 # put a load of file creates/writes/deletes
802 writemany -q $DIR/$tdir/$tfile 0 5 &
806 facet_failover $SINGLEMDS
807 # failover at various points during recovery
808 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
809 echo will failover at $SEQ
812 echo failover in $i sec
814 facet_failover $SINGLEMDS
816 # client process should see no problems even though MDS went down
817 # and recovery was interrupted
819 kill -USR1 $CLIENT_PID
822 echo writemany returned $rc
823 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
825 run_test 51 "failover MDS during recovery"
828 do_facet client "mkdir -p $DIR/$tdir"
829 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
831 echo writemany pid $CLIENT_PID
836 wait $CLIENT_PID || rc=$?
837 # active client process should see an EIO for down OST
838 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
839 # but timing or failover setup may allow success
840 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
841 echo "writemany returned $rc"
846 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
851 [ $rc -ne 0 ] && { return $rc; }
852 # wait for client to reconnect to OST
856 [ $rc -ne 0 ] && { return $rc; }
863 run_test 52 "failover OST under load"
865 # test of open reconstruct
868 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
871 run_test 53 "touch: drop rep"
874 zconf_mount `hostname` $MOUNT2
878 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
881 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
882 [ x"$ERROR" == x ] || error "back in time occured"
884 run_test 54 "back in time"
886 # bug 11330 - liblustre application death during I/O locks up OST
888 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
892 # first dd should be finished quickly
893 lfs setstripe $DIR/$tdir/$tfile-1 -c 1 -i 0
894 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
897 echo "step1: testing ......"
899 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
901 if [ $count -gt 64 ]; then
902 error "dd should be finished!"
906 echo "(dd_pid=$DDPID, time=$count)successful"
908 lfs setstripe $DIR/$tdir/$tfile-2 -c 1 -i 0
909 #define OBD_FAIL_OST_DROP_REQ 0x21d
910 do_facet ost1 lctl set_param fail_loc=0x0000021d
911 # second dd will be never finished
912 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
915 echo "step2: testing ......"
916 while [ $count -le 64 ]; do
917 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
918 if [ -z $dd_name ]; then
920 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
921 error "dd shouldn't be finished!"
926 echo "(dd_pid=$DDPID, time=$count)successful"
928 #Recover fail_loc and dd will finish soon
929 do_facet ost1 lctl set_param fail_loc=0
931 echo "step3: testing ......"
933 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
935 if [ $count -gt 500 ]; then
936 error "dd should be finished!"
940 echo "(dd_pid=$DDPID, time=$count)successful"
944 run_test 55 "ost_brw_read/write drops timed-out read/write request"
946 test_56() { # b=11277
947 #define OBD_FAIL_MDS_RESEND 0x136
949 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
954 run_test 56 "do not allow reconnect to busy exports"
957 # no oscs means no client or mdt
958 while lctl get_param osc.*.* > /dev/null 2>&1; do
959 : # loop until proc file is removed
963 test_57() { # bug 10866
967 #define OBD_FAIL_LPROC_REMOVE 0xB00
968 lctl set_param fail_loc=0x80000B00
969 zconf_umount `hostname` $DIR
970 lctl set_param fail_loc=0x80000B00
971 fail_abort $SINGLEMDS
973 lctl set_param fail_loc=0
975 do_facet client "df $DIR"
977 run_test 57 "read procfs entries causes kernel crash"
979 test_58() { # bug 11546
980 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
983 lctl set_param fail_loc=0x80000801
984 cp $DIR/$tfile /dev/null &
987 lctl set_param fail_loc=0
988 drop_bl_callback rm -f $DIR/$tfile
990 do_facet client "df $DIR"
992 run_test 58 "Eviction in the middle of open RPC reply processing"
994 test_59() { # bug 10589
995 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
996 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
997 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
998 lctl set_param fail_loc=0x311
999 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1000 [ $? = 0 ] || error "dd write failed"
1001 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1002 lctl set_param fail_loc=0
1004 zconf_umount `hostname` $MOUNT2 -f
1005 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1006 [ $? = 0 ] || error "dd read failed"
1007 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1008 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1010 run_test 59 "Read cancel race on client eviction"
1013 # we assume that all md changes are in the MDT0 changelog
1014 if [ $MDSCOUNT -gt 1 ]; then
1015 error_ignore 17935 $*
1022 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
1023 awk '{gsub(/_UUID/,""); print $1}' | head -1)
1028 # Register (and start) changelog
1029 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1030 echo "Registered as $MDT0 changelog user $USER"
1032 # Generate a large number of changelog entries
1033 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1037 # Unlink files in the background
1038 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1042 # Failover the MDS while unlinks are happening
1043 facet_failover $SINGLEMDS
1045 # Wait for unlinkmany to finish
1048 # Check if all the create/unlink events were recorded
1050 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1051 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1052 echo "$cl_count unlinks in $MDT0 changelog"
1054 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1055 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1056 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1057 if [ $USERS -eq 0 ]; then
1058 [ $cl_count -eq $NUM_FILES ] || \
1059 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1060 # Also make sure we can clear large changelogs
1061 cl_count=$($LFS changelog $FSNAME | wc -l)
1062 [ $cl_count -le 2 ] || \
1063 error "Changelog not empty: $cl_count entries"
1065 # If there are other users, there may be other unlinks in the log
1066 [ $cl_count -ge $NUM_FILES ] || \
1067 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1068 echo "$USERS other changelog users; can't verify clear"
1071 run_test 60 "Add Changelog entries during MDS failover"
1075 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1076 mdtosc=${mdtosc/-MDT*/-MDT\*}
1077 local cflags="osc.$mdtosc.connect_flags"
1078 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1079 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1081 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1082 # Set the default stripe of $DIR/$tdir to put the files to ost1
1083 $LFS setstripe -c 1 --index 0 $DIR/$tdir
1085 replay_barrier $SINGLEMDS
1086 createmany -o $DIR/$tdir/$tfile-%d 10
1087 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1089 fail_abort $SINGLEMDS
1091 touch $DIR/$tdir/$tfile
1092 local id=`$LFS getstripe $DIR/$tdir/$tfile |awk '($1 ~ 0 && $2 ~ /^[1-9]+/) {print $2}'`
1093 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1098 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1100 complete $(basename $0) $SECONDS
1101 check_and_cleanup_lustre