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}
15 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
16 CONFIG_EXCEPTIONS="52"
17 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
18 echo "Except the tests: $CONFIG_EXCEPTIONS"
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
22 require_dsh_mds || exit 0
24 # also long tests: 19, 21a, 21e, 21f, 23, 27
25 # 1 2.5 2.5 4 4 (min)"
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
30 # Allow us to override the setup if we already have a mounted system by
31 # setting SETUP=" " and CLEANUP=" "
33 CLEANUP=${CLEANUP:-""}
35 check_and_setup_lustre
38 rm -rf $DIR/[df][0-9]*
41 drop_request "mcreate $DIR/f1" || return 1
42 drop_reint_reply "mcreate $DIR/f2" || return 2
44 run_test 1 "mcreate: drop req, drop rep"
47 drop_request "tchmod 111 $DIR/f2" || return 1
48 drop_reint_reply "tchmod 666 $DIR/f2" || return 2
50 run_test 2 "chmod: drop req, drop rep"
53 drop_request "statone $DIR/f2" || return 1
54 drop_reply "statone $DIR/f2" || return 2
56 run_test 3 "stat: drop req, drop rep"
58 SAMPLE_NAME=f0.recovery-small.junk
59 SAMPLE_FILE=$TMP/$SAMPLE_NAME
60 # make this big, else test 9 doesn't wait for bulk -- bz 5595
61 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
64 do_facet client "cp $SAMPLE_FILE $DIR/$SAMPLE_NAME" || return 1
65 drop_request "cat $DIR/$SAMPLE_NAME > /dev/null" || return 2
66 drop_reply "cat $DIR/$SAMPLE_NAME > /dev/null" || return 3
68 run_test 4 "open: drop req, drop rep"
70 RENAMED_AGAIN=$DIR/f0.renamed-again
73 drop_request "mv $DIR/$SAMPLE_NAME $DIR/$tfile-renamed" || return 1
74 drop_reint_reply "mv $DIR/$tfile-renamed $RENAMED_AGAIN" || return 2
75 do_facet client "checkstat -v $RENAMED_AGAIN" || return 3
77 run_test 5 "rename: drop req, drop rep"
79 [ ! -e $RENAMED_AGAIN ] && cp $SAMPLE_FILE $RENAMED_AGAIN
84 drop_request "mlink $RENAMED_AGAIN $LINK1" || return 1
85 drop_reint_reply "mlink $RENAMED_AGAIN $LINK2" || return 2
87 run_test 6 "link: drop req, drop rep"
89 [ ! -e $LINK1 ] && mlink $RENAMED_AGAIN $LINK1
90 [ ! -e $LINK2 ] && mlink $RENAMED_AGAIN $LINK2
92 drop_request "munlink $LINK1" || return 1
93 drop_reint_reply "munlink $LINK2" || return 2
95 run_test 7 "unlink: drop req, drop rep"
99 drop_reint_reply "touch $DIR/$tfile" || return 1
101 run_test 8 "touch: drop rep (bug 1423)"
105 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
107 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
108 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
109 do_facet client "sync"
110 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
112 run_test 9 "pause bulk on OST (bug 1420)"
116 do_facet client mcreate $DIR/$tfile || return 1
117 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
118 # wait for the mds to evict the client
119 #echo "sleep $(($TIMEOUT*2))"
120 #sleep $(($TIMEOUT*2))
121 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
122 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
123 do_facet client "munlink $DIR/$tfile"
125 run_test 10 "finish request on server after client eviction (bug 1521)"
128 # wake up a thread waiting for completion after eviction
130 do_facet client multiop $DIR/$tfile Ow || return 1
131 do_facet client multiop $DIR/$tfile or || return 2
135 do_facet client multiop $DIR/$tfile or || return 3
136 drop_bl_callback multiop $DIR/$tfile Ow || echo "evicted as expected"
138 do_facet client munlink $DIR/$tfile || return 4
140 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
144 $LCTL mark multiop $DIR/$tfile OS_c
145 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
146 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
147 multiop_bg_pause $DIR/$tfile OS_c || return 1
149 #define OBD_FAIL_MDS_CLOSE_NET 0x115
151 echo "waiting for multiop $PID"
152 wait $PID || return 2
153 do_facet client munlink $DIR/$tfile || return 3
155 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
157 # Bug 113, check that readdir lost recv timeout works.
159 mkdir -p $DIR/$tdir || return 1
160 touch $DIR/$tdir/newentry || return
161 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
162 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
163 ls $DIR/$tdir || return 3
164 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
165 rm -rf $DIR/$tdir || return 4
167 run_test 13 "mdc_readpage restart test (bug 1138)"
169 # Bug 113, check that readdir lost send timeout works.
172 touch $DIR/$tdir/newentry
173 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
175 ls $DIR/$tdir || return 1
176 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
178 run_test 14 "mdc_readpage resend test (bug 1138)"
181 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
182 touch $DIR/$tfile && return 1
185 run_test 15 "failed open (-ENOMEM)"
187 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
189 lctl set_param -n llite.*.max_read_ahead_mb 0
193 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
197 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
199 do_facet client cp $SAMPLE_FILE $DIR
203 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
204 do_facet ost1 "lctl set_param fail_loc=0x80000504"
206 # OST bulk will time out here, client resends
207 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
208 do_facet ost1 lctl set_param fail_loc=0
209 # give recovery a chance to finish (shouldn't take long)
211 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
214 run_test 16 "timeout bulk put, don't evict client (2732)"
219 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
221 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
222 if at_is_enabled; then
223 at_max_saved=$(at_max_get ost1)
224 at_max_set $TIMEOUT ost1
227 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
228 # OST bulk will time out here, client retries
229 do_facet ost1 lctl set_param fail_loc=0x80000503
230 # need to ensure we send an RPC
231 do_facet client cp /etc/termcap $DIR/$tfile
234 # with AT, client will wait adaptive_max*factor+net_latency before
235 # expiring the req, hopefully timeout*2 is enough
236 sleep $(($TIMEOUT*2))
238 do_facet ost1 lctl set_param fail_loc=0
239 do_facet client "df $DIR"
240 # expect cmp to succeed, client resent bulk
241 do_facet client "cmp /etc/termcap $DIR/$tfile" || return 3
242 do_facet client "rm $DIR/$tfile" || return 4
243 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
246 run_test 17 "timeout bulk get, don't evict client (2732)"
249 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
251 do_facet client mkdir -p $DIR/$tdir
255 pgcache_empty || return 1
258 lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
259 get_stripe_info client $f
260 if [ $stripe_index -ne 1 ]; then
262 error "$f: different stripe offset ($stripe_index)" && return
265 do_facet client cp $SAMPLE_FILE $f
267 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
268 $LCTL --device $osc2dev deactivate || return 3
269 # my understanding is that there should be nothing in the page
270 # cache after the client reconnects?
272 pgcache_empty || rc=2
273 $LCTL --device $osc2dev activate
277 run_test 18a "manual ost invalidate clears page cache immediately"
280 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
282 do_facet client mkdir -p $DIR/$tdir
286 pgcache_empty || return 1
288 # shouldn't have to set stripe size of count==1
289 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
290 get_stripe_info client $f
291 if [ $stripe_index -ne 0 ]; then
293 error "$f: different stripe offset ($stripe_index)" && return
296 do_facet client cp $SAMPLE_FILE $f
299 # allow recovery to complete
300 sleep $((TIMEOUT + 2))
301 # my understanding is that there should be nothing in the page
302 # cache after the client reconnects?
304 pgcache_empty || rc=2
308 run_test 18b "eviction and reconnect clears page cache (2766)"
311 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
313 do_facet client mkdir -p $DIR/$tdir
317 pgcache_empty || return 1
319 # shouldn't have to set stripe size of count==1
320 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
321 get_stripe_info client $f
322 if [ $stripe_index -ne 0 ]; then
324 error "$f: different stripe offset ($stripe_index)" && return
327 do_facet client cp $SAMPLE_FILE $f
331 # OBD_FAIL_OST_CONNECT_NET2
332 # lost reply to connect request
333 do_facet ost1 lctl set_param fail_loc=0x80000225
335 df $MOUNT > /dev/null 2>&1
337 # my understanding is that there should be nothing in the page
338 # cache after the client reconnects?
340 pgcache_empty || rc=2
344 run_test 18c "Dropped connect reply after eviction handing (14755)"
348 do_facet client mcreate $f || return 1
349 drop_ldlm_cancel "chmod 0777 $f" || echo "evicted as expected"
351 do_facet client checkstat -v -p 0777 $f || echo evicted
352 # let the client reconnect
354 do_facet client "munlink $f"
356 run_test 19a "test expired_lock_main on mds (2867)"
360 do_facet client multiop $f Ow || return 1
361 do_facet client multiop $f or || return 2
365 do_facet client multiop $f or || return 3
366 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
368 do_facet client munlink $f || return 4
370 run_test 19b "test expired_lock_main on ost (2867)"
372 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
373 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
376 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
377 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
380 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
381 do_facet ost1 lctl set_param fail_loc=0x80000308
382 kill -USR1 $MULTI_PID
385 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
387 run_test 20a "ldlm_handle_enqueue error (should return error)"
389 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
390 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
393 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
395 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
396 do_facet ost1 lctl set_param fail_loc=0x80000308
397 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
398 error "didn't fail open enqueue" || true
400 run_test 20b "ldlm_handle_enqueue error (should return error)"
403 mkdir -p $DIR/$tdir-1
404 mkdir -p $DIR/$tdir-2
405 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
408 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
409 multiop $DIR/$tdir-2/f Oc &
412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
414 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
415 kill -USR1 $close_pid
417 wait $close_pid || return 1
418 wait $open_pid || return 2
419 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
421 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
422 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
426 run_test 21a "drop close request while close and open are both in flight"
429 mkdir -p $DIR/$tdir-1
430 mkdir -p $DIR/$tdir-2
431 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
434 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
435 mcreate $DIR/$tdir-2/f &
438 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
440 kill -USR1 $close_pid
442 wait $close_pid || return 1
443 wait $open_pid || return 3
445 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
446 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
449 run_test 21b "drop open request while close and open are both in flight"
452 mkdir -p $DIR/$tdir-1
453 mkdir -p $DIR/$tdir-2
454 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
457 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
458 mcreate $DIR/$tdir-2/f &
461 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
463 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
464 kill -USR1 $close_pid
466 wait $close_pid || return 1
467 wait $open_pid || return 2
469 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
471 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
472 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
475 run_test 21c "drop both request while close and open are both in flight"
478 mkdir -p $DIR/$tdir-1
479 mkdir -p $DIR/$tdir-2
480 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
483 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
484 multiop $DIR/$tdir-2/f Oc &
486 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
488 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
491 wait $pid || return 1
492 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
494 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
495 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
499 run_test 21d "drop close reply while close and open are both in flight"
502 mkdir -p $DIR/$tdir-1
503 mkdir -p $DIR/$tdir-2
504 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
507 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
508 touch $DIR/$tdir-2/f &
510 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
514 wait $pid || return 1
517 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
518 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
521 run_test 21e "drop open reply while close and open are both in flight"
524 mkdir -p $DIR/$tdir-1
525 mkdir -p $DIR/$tdir-2
526 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
529 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
530 touch $DIR/$tdir-2/f &
532 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
534 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
537 wait $pid || return 1
538 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
540 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
541 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
544 run_test 21f "drop both reply while close and open are both in flight"
547 mkdir -p $DIR/$tdir-1
548 mkdir -p $DIR/$tdir-2
549 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
552 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
553 touch $DIR/$tdir-2/f &
555 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
557 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
560 wait $pid || return 1
561 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
563 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
564 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
567 run_test 21g "drop open reply and close request while close and open are both in flight"
570 mkdir -p $DIR/$tdir-1
571 mkdir -p $DIR/$tdir-2
572 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
575 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
576 touch $DIR/$tdir-2/f &
579 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
581 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
584 wait $pid || return 1
585 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
587 wait $touch_pid || return 2
589 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
590 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
593 run_test 21h "drop open request and close reply while close and open are both in flight"
595 # bug 3462 - multiple MDC requests
600 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
605 multiop $f1 msu || return 1
608 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
610 wait $close_pid || return 2
611 rm -rf $f2 || return 4
613 run_test 22 "drop close request and do mknod"
616 multiop_bg_pause $DIR/$tfile O_c || return 1
618 # give a chance for open
622 drop_request "kill -USR1 $pid"
625 wait $pid || return 1
628 run_test 23 "client hang when close a file after mds crash"
630 test_24() { # bug 11710 details correct fsync() behavior
631 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
634 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
636 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
639 kill -USR1 $MULTI_PID
642 lctl set_param fail_loc=0x0
644 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
646 run_test 24 "fsync error (should return error)"
648 wait_client_evicted () {
651 local varsvc=${facet}_svc
653 wait_update $(facet_host $facet) "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" $((exports - 1)) $3
656 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
657 # this test can only run from a client on a separate node.
658 remote_ost || { skip "local OST" && return 0; }
659 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
660 remote_mds || { skip "local MDS" && return 0; }
662 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
663 skip "msg and ost1 are at the same node"
667 check_timeout || return 1
669 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
671 echo starting with $OST_NEXP OST exports
672 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
673 do_facet client lctl set_param fail_loc=0x505
674 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
675 # But if there's a race to start the evictor from various obds,
676 # the loser might have to wait for the next ping.
679 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
681 do_facet client lctl set_param fail_loc=0x0
682 [ $rc -eq 0 ] || error "client not evicted from OST"
684 run_test 26a "evict dead exports"
686 test_26b() { # bug 10140 - evict dead exports by pinger
687 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
689 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
690 skip "msg and ost1 are at the same node"
694 check_timeout || return 1
696 zconf_mount `hostname` $MOUNT2 ||
697 { error "Failed to mount $MOUNT2"; return 2; }
698 sleep 1 # wait connections being established
700 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
701 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
703 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
705 zconf_umount `hostname` $MOUNT2 -f
707 # PING_INTERVAL max(obd_timeout / 4, 1U)
708 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
710 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
711 # But if there's a race to start the evictor from various obds,
712 # the loser might have to wait for the next ping.
713 # = 9 * PING_INTERVAL + PING_INTERVAL
714 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
715 # let's wait $((TIMEOUT * 3)) # bug 19887
717 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
718 error "Client was not evicted by ost" rc=1
719 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
720 error "Client was not evicted by mds"
722 run_test 26b "evict dead exports"
726 writemany -q -a $DIR/$tdir/$tfile 0 5 &
729 local save_FAILURE_MODE=$FAILURE_MODE
731 facet_failover $SINGLEMDS
732 #define OBD_FAIL_OSC_SHUTDOWN 0x407
733 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
734 # need to wait for reconnect
735 echo -n waiting for fail_loc
736 while [ $(do_facet $SINGLEMDS lctl get_param -n fail_loc) -eq -2147482617 ]; do
740 do_facet $SINGLEMDS lctl get_param -n fail_loc
741 facet_failover $SINGLEMDS
743 kill -USR1 $CLIENT_PID
746 FAILURE_MODE=$save_FAILURE_MODE
748 run_test 27 "fail LOV while using OSC's"
750 test_28() { # bug 6086 - error adding new clients
751 do_facet client mcreate $DIR/$tfile || return 1
752 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
753 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
754 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
755 # fail once (evicted), reconnect fail (fail_loc), ok
756 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
758 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
760 run_test 28 "handle error adding new clients (bug 6086)"
762 test_29a() { # bug 22273 - error adding new clients
763 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
764 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
765 # fail abort so client will be new again
766 fail_abort $SINGLEMDS
767 client_up || error "reconnect failed"
770 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
772 test_29b() { # bug 22273 - error adding new clients
773 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
774 do_facet ost1 "lctl set_param fail_loc=0x80000711"
775 # fail abort so client will be new again
777 client_up || error "reconnect failed"
780 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
784 # put a load of file creates/writes/deletes
785 writemany -q $DIR/$tdir/$tfile 0 5 &
787 echo writemany pid $CLIENT_PID
791 # wait for client to reconnect to MDS
796 # client process should see no problems even though MDS went down
798 kill -USR1 $CLIENT_PID
801 echo writemany returned $rc
802 #these may fail because of eviction due to slow AST response.
803 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
805 run_test 50 "failover MDS under load"
808 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
809 do_facet ost1 lctl set_param fail_loc=0x00001310
812 # put a load of file creates/writes/deletes
813 writemany -q $DIR/$tdir/$tfile 0 5 &
817 facet_failover $SINGLEMDS
818 # failover at various points during recovery
819 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
820 echo will failover at $SEQ
823 echo failover in $i sec
825 facet_failover $SINGLEMDS
827 # client process should see no problems even though MDS went down
828 # and recovery was interrupted
830 kill -USR1 $CLIENT_PID
833 echo writemany returned $rc
834 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
836 run_test 51 "failover MDS during recovery"
839 do_facet client "mkdir -p $DIR/$tdir"
840 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
842 echo writemany pid $CLIENT_PID
847 wait $CLIENT_PID || rc=$?
848 # active client process should see an EIO for down OST
849 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
850 # but timing or failover setup may allow success
851 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
852 echo "writemany returned $rc"
857 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
862 [ $rc -ne 0 ] && { return $rc; }
863 # wait for client to reconnect to OST
867 [ $rc -ne 0 ] && { return $rc; }
874 run_test 52 "failover OST under load"
876 # test of open reconstruct
879 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
882 run_test 53 "touch: drop rep"
885 zconf_mount `hostname` $MOUNT2
889 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
892 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
893 [ x"$ERROR" == x ] || error "back in time occured"
895 run_test 54 "back in time"
897 # bug 11330 - liblustre application death during I/O locks up OST
899 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
903 # first dd should be finished quickly
904 lfs setstripe $DIR/$tdir/$tfile-1 -c 1 -i 0
905 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
908 echo "step1: testing ......"
910 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
912 if [ $count -gt 64 ]; then
913 error "dd should be finished!"
917 echo "(dd_pid=$DDPID, time=$count)successful"
919 lfs setstripe $DIR/$tdir/$tfile-2 -c 1 -i 0
920 #define OBD_FAIL_OST_DROP_REQ 0x21d
921 do_facet ost1 lctl set_param fail_loc=0x0000021d
922 # second dd will be never finished
923 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
926 echo "step2: testing ......"
927 while [ $count -le 64 ]; do
928 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
929 if [ -z $dd_name ]; then
931 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
932 error "dd shouldn't be finished!"
937 echo "(dd_pid=$DDPID, time=$count)successful"
939 #Recover fail_loc and dd will finish soon
940 do_facet ost1 lctl set_param fail_loc=0
942 echo "step3: testing ......"
944 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
946 if [ $count -gt 500 ]; then
947 error "dd should be finished!"
951 echo "(dd_pid=$DDPID, time=$count)successful"
955 run_test 55 "ost_brw_read/write drops timed-out read/write request"
957 test_56() { # b=11277
958 #define OBD_FAIL_MDS_RESEND 0x136
960 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
962 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
965 run_test 56 "do not allow reconnect to busy exports"
968 # no oscs means no client or mdt
969 while lctl get_param osc.*.* > /dev/null 2>&1; do
970 : # loop until proc file is removed
974 test_57() { # bug 10866
978 #define OBD_FAIL_LPROC_REMOVE 0xB00
979 lctl set_param fail_loc=0x80000B00
980 zconf_umount `hostname` $DIR
981 lctl set_param fail_loc=0x80000B00
982 fail_abort $SINGLEMDS
984 lctl set_param fail_loc=0
986 do_facet client "df $DIR"
988 run_test 57 "read procfs entries causes kernel crash"
990 test_58() { # bug 11546
991 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
994 lctl set_param fail_loc=0x80000801
995 cp $DIR/$tfile /dev/null &
998 lctl set_param fail_loc=0
999 drop_bl_callback rm -f $DIR/$tfile
1001 do_facet client "df $DIR"
1003 run_test 58 "Eviction in the middle of open RPC reply processing"
1005 test_59() { # bug 10589
1006 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1007 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1008 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1009 lctl set_param fail_loc=0x311
1010 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1011 [ $? = 0 ] || error "dd write failed"
1012 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1013 lctl set_param fail_loc=0
1015 zconf_umount `hostname` $MOUNT2 -f
1016 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1017 [ $? = 0 ] || error "dd read failed"
1018 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1019 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1021 run_test 59 "Read cancel race on client eviction"
1024 # we assume that all md changes are in the MDT0 changelog
1025 if [ $MDSCOUNT -gt 1 ]; then
1026 error_ignore 17935 $*
1033 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
1034 awk '{gsub(/_UUID/,""); print $1}' | head -1)
1039 # Register (and start) changelog
1040 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1041 echo "Registered as $MDT0 changelog user $USER"
1043 # Generate a large number of changelog entries
1044 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1048 # Unlink files in the background
1049 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1053 # Failover the MDS while unlinks are happening
1054 facet_failover $SINGLEMDS
1056 # Wait for unlinkmany to finish
1059 # Check if all the create/unlink events were recorded
1061 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1062 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1063 echo "$cl_count unlinks in $MDT0 changelog"
1065 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1066 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1067 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1068 if [ $USERS -eq 0 ]; then
1069 [ $cl_count -eq $NUM_FILES ] || \
1070 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1071 # Also make sure we can clear large changelogs
1072 cl_count=$($LFS changelog $FSNAME | wc -l)
1073 [ $cl_count -le 2 ] || \
1074 error "Changelog not empty: $cl_count entries"
1076 # If there are other users, there may be other unlinks in the log
1077 [ $cl_count -ge $NUM_FILES ] || \
1078 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1079 echo "$USERS other changelog users; can't verify clear"
1082 run_test 60 "Add Changelog entries during MDS failover"
1086 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1087 mdtosc=${mdtosc/-MDT*/-MDT\*}
1088 local cflags="osc.$mdtosc.connect_flags"
1089 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1090 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1092 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1093 # Set the default stripe of $DIR/$tdir to put the files to ost1
1094 $LFS setstripe -c 1 --index 0 $DIR/$tdir
1096 replay_barrier $SINGLEMDS
1097 createmany -o $DIR/$tdir/$tfile-%d 10
1098 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1100 fail_abort $SINGLEMDS
1102 touch $DIR/$tdir/$tfile
1103 local id=`$LFS getstripe $DIR/$tdir/$tfile |awk '($1 ~ 0 && $2 ~ /^[1-9]+/) {print $2}'`
1104 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1109 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1111 equals_msg `basename $0`: test complete, cleaning up
1112 check_and_cleanup_lustre
1113 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true