6 ALWAYS_EXCEPT="24 27 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}
14 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
15 CONFIG_EXCEPTIONS="52"
16 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
17 echo "Except the tests: $CONFIG_EXCEPTIONS"
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
21 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
23 # also long tests: 19, 21a, 21e, 21f, 23, 27
24 # 1 2.5 2.5 4 4 (min)"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
29 # Allow us to override the setup if we already have a mounted system by
30 # setting SETUP=" " and CLEANUP=" "
32 CLEANUP=${CLEANUP:-""}
34 check_and_setup_lustre
37 rm -rf $DIR/[df][0-9]*
40 drop_request "mcreate $DIR/f1" || return 1
41 drop_reint_reply "mcreate $DIR/f2" || return 2
43 run_test 1 "mcreate: drop req, drop rep"
46 drop_request "tchmod 111 $DIR/f2" || return 1
47 drop_reint_reply "tchmod 666 $DIR/f2" || return 2
49 run_test 2 "chmod: drop req, drop rep"
52 drop_request "statone $DIR/f2" || return 1
53 drop_reply "statone $DIR/f2" || return 2
55 run_test 3 "stat: drop req, drop rep"
57 SAMPLE_NAME=f0.recovery-small.junk
58 SAMPLE_FILE=$TMP/$SAMPLE_NAME
59 # make this big, else test 9 doesn't wait for bulk -- bz 5595
60 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
63 do_facet client "cp $SAMPLE_FILE $DIR/$SAMPLE_NAME" || return 1
64 drop_request "cat $DIR/$SAMPLE_NAME > /dev/null" || return 2
65 drop_reply "cat $DIR/$SAMPLE_NAME > /dev/null" || return 3
67 run_test 4 "open: drop req, drop rep"
69 RENAMED_AGAIN=$DIR/f0.renamed-again
72 drop_request "mv $DIR/$SAMPLE_NAME $DIR/$tfile-renamed" || return 1
73 drop_reint_reply "mv $DIR/$tfile-renamed $RENAMED_AGAIN" || return 2
74 do_facet client "checkstat -v $RENAMED_AGAIN" || return 3
76 run_test 5 "rename: drop req, drop rep"
78 [ ! -e $RENAMED_AGAIN ] && cp $SAMPLE_FILE $RENAMED_AGAIN
83 drop_request "mlink $RENAMED_AGAIN $LINK1" || return 1
84 drop_reint_reply "mlink $RENAMED_AGAIN $LINK2" || return 2
86 run_test 6 "link: drop req, drop rep"
88 [ ! -e $LINK1 ] && mlink $RENAMED_AGAIN $LINK1
89 [ ! -e $LINK2 ] && mlink $RENAMED_AGAIN $LINK2
91 drop_request "munlink $LINK1" || return 1
92 drop_reint_reply "munlink $LINK2" || return 2
94 run_test 7 "unlink: drop req, drop rep"
98 drop_reint_reply "touch $DIR/$tfile" || return 1
100 run_test 8 "touch: drop rep (bug 1423)"
104 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
106 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
107 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
108 do_facet client "sync"
109 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
111 run_test 9 "pause bulk on OST (bug 1420)"
115 do_facet client mcreate $DIR/$tfile || return 1
116 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
117 # wait for the mds to evict the client
118 #echo "sleep $(($TIMEOUT*2))"
119 #sleep $(($TIMEOUT*2))
120 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
121 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
122 do_facet client "munlink $DIR/$tfile"
124 run_test 10 "finish request on server after client eviction (bug 1521)"
127 # wake up a thread waiting for completion after eviction
129 do_facet client multiop $DIR/$tfile Ow || return 1
130 do_facet client multiop $DIR/$tfile or || return 2
134 do_facet client multiop $DIR/$tfile or || return 3
135 drop_bl_callback multiop $DIR/$tfile Ow || echo "evicted as expected"
137 do_facet client munlink $DIR/$tfile || return 4
139 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
143 $LCTL mark multiop $DIR/$tfile OS_c
144 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
145 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
146 multiop_bg_pause $DIR/$tfile OS_c || return 1
148 #define OBD_FAIL_MDS_CLOSE_NET 0x115
150 echo "waiting for multiop $PID"
151 wait $PID || return 2
152 do_facet client munlink $DIR/$tfile || return 3
154 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
156 # Bug 113, check that readdir lost recv timeout works.
158 mkdir -p $DIR/$tdir || return 1
159 touch $DIR/$tdir/newentry || return
160 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
161 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
162 ls $DIR/$tdir || return 3
163 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
164 rm -rf $DIR/$tdir || return 4
166 run_test 13 "mdc_readpage restart test (bug 1138)"
168 # Bug 113, check that readdir lost send timeout works.
171 touch $DIR/$tdir/newentry
172 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
173 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
174 ls $DIR/$tdir || return 1
175 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
177 run_test 14 "mdc_readpage resend test (bug 1138)"
180 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
181 touch $DIR/$tfile && return 1
184 run_test 15 "failed open (-ENOMEM)"
186 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
188 lctl set_param -n llite.*.max_read_ahead_mb 0
192 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
196 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
198 do_facet client cp $SAMPLE_FILE $DIR
202 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
203 do_facet ost1 "lctl set_param fail_loc=0x80000504"
205 # OST bulk will time out here, client resends
206 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
207 do_facet ost1 lctl set_param fail_loc=0
208 # give recovery a chance to finish (shouldn't take long)
210 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
213 run_test 16 "timeout bulk put, don't evict client (2732)"
218 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
220 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
221 if at_is_valid && at_is_enabled; then
222 at_max_saved=$(at_max_get ost1)
223 at_max_set $TIMEOUT ost1
226 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
227 # OST bulk will time out here, client retries
228 do_facet ost1 lctl set_param fail_loc=0x80000503
229 # need to ensure we send an RPC
230 do_facet client cp /etc/termcap $DIR/$tfile
233 # with AT, client will wait adaptive_max*factor+net_latency before
234 # expiring the req, hopefully timeout*2 is enough
235 sleep $(($TIMEOUT*2))
237 do_facet ost1 lctl set_param fail_loc=0
238 do_facet client "df $DIR"
239 # expect cmp to succeed, client resent bulk
240 do_facet client "cmp /etc/termcap $DIR/$tfile" || return 3
241 do_facet client "rm $DIR/$tfile" || return 4
242 [ $at_max_saved -ne 0 ] && $(at_max_set $at_max_saved ost1)
245 run_test 17 "timeout bulk get, don't evict client (2732)"
248 [ -z ${ost2_svc} ] && skip "needs 2 osts" && return 0
250 do_facet client mkdir -p $DIR/$tdir
254 pgcache_empty || return 1
257 lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
258 get_stripe_info client $f
259 if [ $stripe_index -ne 1 ]; then
261 error "$f: different stripe offset ($stripe_index)" && return
264 do_facet client cp $SAMPLE_FILE $f
266 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
267 $LCTL --device $osc2dev deactivate || return 3
268 # my understanding is that there should be nothing in the page
269 # cache after the client reconnects?
271 pgcache_empty || rc=2
272 $LCTL --device $osc2dev activate
276 run_test 18a "manual ost invalidate clears page cache immediately"
279 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
281 do_facet client mkdir -p $DIR/$tdir
285 pgcache_empty || return 1
287 # shouldn't have to set stripe size of count==1
288 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
289 get_stripe_info client $f
290 if [ $stripe_index -ne 0 ]; then
292 error "$f: different stripe offset ($stripe_index)" && return
295 do_facet client cp $SAMPLE_FILE $f
298 # allow recovery to complete
299 sleep $((TIMEOUT + 2))
300 # my understanding is that there should be nothing in the page
301 # cache after the client reconnects?
303 pgcache_empty || rc=2
307 run_test 18b "eviction and reconnect clears page cache (2766)"
310 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
312 do_facet client mkdir -p $DIR/$tdir
316 pgcache_empty || return 1
318 # shouldn't have to set stripe size of count==1
319 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
320 get_stripe_info client $f
321 if [ $stripe_index -ne 0 ]; then
323 error "$f: different stripe offset ($stripe_index)" && return
326 do_facet client cp $SAMPLE_FILE $f
330 # OBD_FAIL_OST_CONNECT_NET2
331 # lost reply to connect request
332 do_facet ost1 lctl set_param fail_loc=0x80000225
334 df $MOUNT > /dev/null 2>&1
336 # my understanding is that there should be nothing in the page
337 # cache after the client reconnects?
339 pgcache_empty || rc=2
343 run_test 18c "Dropped connect reply after eviction handing (14755)"
347 do_facet client mcreate $f || return 1
348 drop_ldlm_cancel "chmod 0777 $f" || echo "evicted as expected"
350 do_facet client checkstat -v -p 0777 $f || echo evicted
351 # let the client reconnect
353 do_facet client "munlink $f"
355 run_test 19a "test expired_lock_main on mds (2867)"
359 do_facet client multiop $f Ow || return 1
360 do_facet client multiop $f or || return 2
364 do_facet client multiop $f or || return 3
365 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
367 do_facet client munlink $f || return 4
369 run_test 19b "test expired_lock_main on ost (2867)"
371 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
372 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
375 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
376 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
379 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
380 do_facet ost1 lctl set_param fail_loc=0x80000308
381 kill -USR1 $MULTI_PID
384 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
386 run_test 20a "ldlm_handle_enqueue error (should return error)"
388 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
389 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
392 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
394 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
395 do_facet ost1 lctl set_param fail_loc=0x80000308
396 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
397 error "didn't fail open enqueue" || true
399 run_test 20b "ldlm_handle_enqueue error (should return error)"
402 mkdir -p $DIR/$tdir-1
403 mkdir -p $DIR/$tdir-2
404 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
407 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
408 multiop $DIR/$tdir-2/f Oc &
411 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
413 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
414 kill -USR1 $close_pid
416 wait $close_pid || return 1
417 wait $open_pid || return 2
418 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
420 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
421 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
425 run_test 21a "drop close request while close and open are both in flight"
428 mkdir -p $DIR/$tdir-1
429 mkdir -p $DIR/$tdir-2
430 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
433 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
434 mcreate $DIR/$tdir-2/f &
437 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
439 kill -USR1 $close_pid
441 wait $close_pid || return 1
442 wait $open_pid || return 3
444 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
445 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
448 run_test 21b "drop open request while close and open are both in flight"
451 mkdir -p $DIR/$tdir-1
452 mkdir -p $DIR/$tdir-2
453 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
456 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
457 mcreate $DIR/$tdir-2/f &
460 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
462 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
463 kill -USR1 $close_pid
465 wait $close_pid || return 1
466 wait $open_pid || return 2
468 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
470 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
471 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
474 run_test 21c "drop both request while close and open are both in flight"
477 mkdir -p $DIR/$tdir-1
478 mkdir -p $DIR/$tdir-2
479 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
482 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
483 multiop $DIR/$tdir-2/f Oc &
485 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
490 wait $pid || return 1
491 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
493 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
494 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
498 run_test 21d "drop close reply while close and open are both in flight"
501 mkdir -p $DIR/$tdir-1
502 mkdir -p $DIR/$tdir-2
503 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
506 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
507 touch $DIR/$tdir-2/f &
509 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
513 wait $pid || return 1
516 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
517 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
520 run_test 21e "drop open reply while close and open are both in flight"
523 mkdir -p $DIR/$tdir-1
524 mkdir -p $DIR/$tdir-2
525 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
528 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
529 touch $DIR/$tdir-2/f &
531 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
533 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
536 wait $pid || return 1
537 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
539 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
540 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
543 run_test 21f "drop both reply while close and open are both in flight"
546 mkdir -p $DIR/$tdir-1
547 mkdir -p $DIR/$tdir-2
548 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
551 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
552 touch $DIR/$tdir-2/f &
554 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
556 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
559 wait $pid || return 1
560 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
562 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
563 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
566 run_test 21g "drop open reply and close request while close and open are both in flight"
569 mkdir -p $DIR/$tdir-1
570 mkdir -p $DIR/$tdir-2
571 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
574 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
575 touch $DIR/$tdir-2/f &
578 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
580 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
583 wait $pid || return 1
584 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
586 wait $touch_pid || return 2
588 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
589 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
592 run_test 21h "drop open request and close reply while close and open are both in flight"
594 # bug 3462 - multiple MDC requests
599 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
604 multiop $f1 msu || return 1
607 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
609 wait $close_pid || return 2
610 rm -rf $f2 || return 4
612 run_test 22 "drop close request and do mknod"
615 multiop_bg_pause $DIR/$tfile O_c || return 1
617 # give a chance for open
621 drop_request "kill -USR1 $pid"
624 wait $pid || return 1
627 run_test 23 "client hang when close a file after mds crash"
629 test_24() { # bug 11710 details correct fsync() behavior
630 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
633 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
635 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
638 kill -USR1 $MULTI_PID
641 lctl set_param fail_loc=0x0
643 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
645 run_test 24 "fsync error (should return error)"
647 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
648 # this test can only run from a client on a separate node.
649 remote_ost || { skip "local OST" && return 0; }
650 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
651 remote_mds || { skip "local MDS" && return 0; }
652 OST_FILE=obdfilter.${ost1_svc}.num_exports
653 OST_EXP="`do_facet ost1 lctl get_param -n $OST_FILE`"
654 OST_NEXP1=`echo $OST_EXP | cut -d' ' -f2`
655 echo starting with $OST_NEXP1 OST exports
656 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
657 do_facet client lctl set_param fail_loc=0x505
658 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
659 # But if there's a race to start the evictor from various obds,
660 # the loser might have to wait for the next ping.
661 echo Waiting for $(($TIMEOUT * 8)) secs
662 sleep $(($TIMEOUT * 8))
663 OST_EXP="`do_facet ost1 lctl get_param -n $OST_FILE`"
664 OST_NEXP2=`echo $OST_EXP | cut -d' ' -f2`
665 echo ending with $OST_NEXP2 OST exports
666 do_facet client lctl set_param fail_loc=0x0
667 [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted"
670 run_test 26a "evict dead exports"
672 test_26b() { # bug 10140 - evict dead exports by pinger
673 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
676 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
677 sleep 1 # wait connections being established
678 MDS_FILE=mdt.${mds1_svc}.num_exports
679 MDS_NEXP1="`do_facet $SINGLEMDS lctl get_param -n $MDS_FILE | cut -d' ' -f2`"
680 OST_FILE=obdfilter.${ost1_svc}.num_exports
681 OST_NEXP1="`do_facet ost1 lctl get_param -n $OST_FILE | cut -d' ' -f2`"
682 echo starting with $OST_NEXP1 OST and $MDS_NEXP1 MDS exports
683 zconf_umount `hostname` $MOUNT2 -f
684 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
685 # But if there's a race to start the evictor from various obds,
686 # the loser might have to wait for the next ping.
687 echo Waiting for $(($TIMEOUT * 3)) secs
688 sleep $(($TIMEOUT * 3))
689 OST_NEXP2="`do_facet ost1 lctl get_param -n $OST_FILE | cut -d' ' -f2`"
690 MDS_NEXP2="`do_facet $SINGLEMDS lctl get_param -n $MDS_FILE | cut -d' ' -f2`"
691 echo ending with $OST_NEXP2 OST and $MDS_NEXP2 MDS exports
692 [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted from OST"
693 [ $MDS_NEXP1 -le $MDS_NEXP2 ] && error "client not evicted from MDS"
696 run_test 26b "evict dead exports"
700 writemany -q -a $DIR/$tdir/$tfile 0 5 &
703 local save_FAILURE_MODE=$FAILURE_MODE
705 facet_failover $SINGLEMDS
706 #define OBD_FAIL_OSC_SHUTDOWN 0x407
707 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
708 # need to wait for reconnect
709 echo -n waiting for fail_loc
710 while [ $(do_facet $SINGLEMDS lctl get_param -n fail_loc) -eq -2147482617 ]; do
714 do_facet $SINGLEMDS lctl get_param -n fail_loc
715 facet_failover $SINGLEMDS
717 kill -USR1 $CLIENT_PID
720 FAILURE_MODE=$save_FAILURE_MODE
722 run_test 27 "fail LOV while using OSC's"
724 test_28() { # bug 6086 - error adding new clients
725 do_facet client mcreate $DIR/$tfile || return 1
726 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
727 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
728 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
729 # fail once (evicted), reconnect fail (fail_loc), ok
730 df || (sleep 10; df) || (sleep 10; df) || error "reconnect failed"
732 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
734 run_test 28 "handle error adding new clients (bug 6086)"
738 # put a load of file creates/writes/deletes
739 writemany -q $DIR/$tdir/$tfile 0 5 &
741 echo writemany pid $CLIENT_PID
745 # wait for client to reconnect to MDS
750 # client process should see no problems even though MDS went down
752 kill -USR1 $CLIENT_PID
755 echo writemany returned $rc
756 #these may fail because of eviction due to slow AST response.
757 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
759 run_test 50 "failover MDS under load"
763 # put a load of file creates/writes/deletes
764 writemany -q $DIR/$tdir/$tfile 0 5 &
768 facet_failover $SINGLEMDS
769 # failover at various points during recovery
770 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
771 echo will failover at $SEQ
774 echo failover in $i sec
776 facet_failover $SINGLEMDS
778 # client process should see no problems even though MDS went down
779 # and recovery was interrupted
781 kill -USR1 $CLIENT_PID
784 echo writemany returned $rc
785 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
787 run_test 51 "failover MDS during recovery"
790 do_facet client "mkdir -p $DIR/$tdir"
791 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
793 echo writemany pid $CLIENT_PID
798 wait $CLIENT_PID || rc=$?
799 # active client process should see an EIO for down OST
800 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
801 # but timing or failover setup may allow success
802 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
803 echo "writemany returned $rc"
808 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
813 [ $rc -ne 0 ] && { return $rc; }
814 # wait for client to reconnect to OST
818 [ $rc -ne 0 ] && { return $rc; }
825 run_test 52 "failover OST under load"
827 # test of open reconstruct
830 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
833 run_test 53 "touch: drop rep"
836 zconf_mount `hostname` $MOUNT2
840 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
843 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
844 [ x"$ERROR" == x ] || error "back in time occured"
846 run_test 54 "back in time"
848 # bug 11330 - liblustre application death during I/O locks up OST
850 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
854 # first dd should be finished quickly
855 lfs setstripe $DIR/$tdir/$tfile-1 -c 1 -i 0
856 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
859 echo "step1: testing ......"
861 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
863 if [ $count -gt 64 ]; then
864 error "dd should be finished!"
868 echo "(dd_pid=$DDPID, time=$count)successful"
870 lfs setstripe $DIR/$tdir/$tfile-2 -c 1 -i 0
871 #define OBD_FAIL_OST_DROP_REQ 0x21d
872 do_facet ost1 lctl set_param fail_loc=0x0000021d
873 # second dd will be never finished
874 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
877 echo "step2: testing ......"
878 while [ $count -le 64 ]; do
879 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
880 if [ -z $dd_name ]; then
882 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
883 error "dd shouldn't be finished!"
888 echo "(dd_pid=$DDPID, time=$count)successful"
890 #Recover fail_loc and dd will finish soon
891 do_facet ost1 lctl set_param fail_loc=0
893 echo "step3: testing ......"
895 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
897 if [ $count -gt 500 ]; then
898 error "dd should be finished!"
902 echo "(dd_pid=$DDPID, time=$count)successful"
906 run_test 55 "ost_brw_read/write drops timed-out read/write request"
908 test_56() { # b=11277
909 #define OBD_FAIL_MDS_RESEND 0x136
911 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
913 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
916 run_test 56 "do not allow reconnect to busy exports"
919 # no oscs means no client or mdt
920 while lctl get_param osc.*.* > /dev/null 2>&1; do
921 : # loop until proc file is removed
925 test_57() { # bug 10866
929 #define OBD_FAIL_LPROC_REMOVE 0xB00
930 lctl set_param fail_loc=0x80000B00
931 zconf_umount `hostname` $DIR
932 lctl set_param fail_loc=0x80000B00
933 fail_abort $SINGLEMDS
935 lctl set_param fail_loc=0
937 do_facet client "df $DIR"
939 run_test 57 "read procfs entries causes kernel crash"
941 test_58() { # bug 11546
942 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
945 lctl set_param fail_loc=0x80000801
946 cp $DIR/$tfile /dev/null &
949 lctl set_param fail_loc=0
950 drop_bl_callback rm -f $DIR/$tfile
952 do_facet client "df $DIR"
954 run_test 58 "Eviction in the middle of open RPC reply processing"
956 test_59() { # bug 10589
957 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
958 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
959 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
960 lctl set_param fail_loc=0x311
961 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
962 [ $? = 0 ] || error "dd write failed"
963 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
964 lctl set_param fail_loc=0
966 zconf_umount `hostname` $MOUNT2 -f
967 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
968 [ $? = 0 ] || error "dd read failed"
969 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
970 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
972 run_test 59 "Read cancel race on client eviction"
975 if [ $MDSCOUNT -gt 1 ]; then
976 error_ignore 17935 $*
983 remote_mds && { skip "remote MDS" && return 0; }
988 # Enable and clear changelog
989 $LCTL conf_param ${mds1_svc}.mdd.changelog=on
990 $LCTL set_param -n mdd.*.changelog on
991 $LFS changelog_clear $FSNAME 0
993 # Create NUM_FILES in the background
994 createmany -o $DIR/$tdir/$tfile $NUM_FILES
998 # Unlink files in the background
999 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1003 # Failover the MDS while creates are happening
1004 facet_failover $SINGLEMDS
1006 # Wait for unlinkmany to finish
1009 # Check if NUM_FILES create/unlink events were recorded
1011 $LFS changelog $FSNAME >> $DIR/$tdir/changelog
1012 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1013 echo "$cl_count unlinks in changelog"
1015 [ $cl_count -eq $NUM_FILES ] || err17935 "Recorded ${cl_count} unlinks out
1018 # Also make sure we can clear large changelogs
1019 lctl set_param -n mdd.*.changelog off
1020 $LFS changelog_clear $FSNAME 0
1022 cl_count=$($LFS changelog $FSNAME | wc -l)
1023 [ $cl_count -eq 1 ] || error "Changelog not empty: $cl_count entries"
1025 run_test 60 "Add Changelog entries during MDS failover"
1027 equals_msg `basename $0`: test complete, cleaning up
1028 check_and_cleanup_lustre
1029 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true