6 ALWAYS_EXCEPT="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 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
16 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
17 CONFIG_EXCEPTIONS="52"
18 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
19 echo "Except the tests: $CONFIG_EXCEPTIONS"
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
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)"
102 SAMPLE_FILE=$TMP/recovery-small.junk
103 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
107 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
109 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
110 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
111 do_facet client "sync"
112 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
114 run_test 9 "pause bulk on OST (bug 1420)"
118 do_facet client mcreate $DIR/$tfile || return 1
119 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
120 # wait for the mds to evict the client
121 #echo "sleep $(($TIMEOUT*2))"
122 #sleep $(($TIMEOUT*2))
123 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
124 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
125 do_facet client "munlink $DIR/$tfile"
127 run_test 10 "finish request on server after client eviction (bug 1521)"
130 # wake up a thread waiting for completion after eviction
132 do_facet client multiop $DIR/$tfile Ow || return 1
133 do_facet client multiop $DIR/$tfile or || return 2
137 do_facet client multiop $DIR/$tfile or || return 3
138 drop_bl_callback multiop $DIR/$tfile Ow || echo "evicted as expected"
140 do_facet client munlink $DIR/$tfile || return 4
142 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
146 $LCTL mark multiop $DIR/$tfile OS_c
147 do_facet mds "lctl set_param fail_loc=0x115"
148 clear_failloc mds $((TIMEOUT * 2)) &
149 multiop_bg_pause $DIR/$tfile OS_c || return 1
151 #define OBD_FAIL_MDS_CLOSE_NET 0x115
153 echo "waiting for multiop $PID"
154 wait $PID || return 2
155 do_facet client munlink $DIR/$tfile || return 3
157 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
159 # Bug 113, check that readdir lost recv timeout works.
161 mkdir -p $DIR/$tdir || return 1
162 touch $DIR/$tdir/newentry || return
163 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
164 do_facet mds "lctl set_param fail_loc=0x80000104"
165 ls $DIR/$tdir || return 3
166 do_facet mds "lctl set_param fail_loc=0"
167 rm -rf $DIR/$tdir || return 4
169 run_test 13 "mdc_readpage restart test (bug 1138)"
171 # Bug 113, check that readdir lost send timeout works.
174 touch $DIR/$tdir/newentry
175 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
176 do_facet mds "lctl set_param fail_loc=0x80000106"
177 ls $DIR/$tdir || return 1
178 do_facet mds "lctl set_param fail_loc=0"
180 run_test 14 "mdc_readpage resend test (bug 1138)"
183 do_facet mds "lctl set_param fail_loc=0x80000128"
184 touch $DIR/$tfile && return 1
187 run_test 15 "failed open (-ENOMEM)"
189 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
191 lctl set_param -n llite.*.max_read_ahead_mb 0
195 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
199 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
201 do_facet client cp $SAMPLE_FILE $DIR
205 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
206 do_facet ost1 lctl set_param fail_loc=0x80000504
208 # OST bulk will time out here, client resends
209 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
210 do_facet ost1 lctl set_param fail_loc=0
211 # give recovery a chance to finish (shouldn't take long)
213 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
216 run_test 16 "timeout bulk put, don't evict client (2732)"
221 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
223 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
224 if at_is_enabled; then
225 at_max_saved=$(at_max_get ost1)
226 at_max_set $TIMEOUT ost1
229 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
230 # OST bulk will time out here, client retries
231 do_facet client lctl set_param fail_loc=0x80000503
232 # need to ensure we send an RPC
233 do_facet client cp $SAMPLE_FILE $DIR/$tfile
236 # with AT, client will wait adaptive_max*factor+net_latency before
237 # expiring the req, hopefully timeout*2 is enough
238 sleep $(($TIMEOUT*2))
240 do_facet ost1 lctl set_param fail_loc=0
241 do_facet client "df $DIR"
242 # expect cmp to succeed, client resent bulk
243 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
244 do_facet client "rm $DIR/$tfile" || return 4
245 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
248 run_test 17 "timeout bulk get, don't evict client (2732)"
251 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
253 do_facet client mkdir -p $DIR/$tdir
257 pgcache_empty || return 1
260 lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
261 get_stripe_info client $f
262 if [ $stripe_index -ne 1 ]; then
264 error "$f: different stripe offset ($stripe_index)" && return
267 do_facet client cp $SAMPLE_FILE $f
269 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | awk '{print $1}'`
270 $LCTL --device $osc2dev deactivate || return 3
271 # my understanding is that there should be nothing in the page
272 # cache after the client reconnects?
274 pgcache_empty || rc=2
275 $LCTL --device $osc2dev activate
279 run_test 18a "manual ost invalidate clears page cache immediately"
282 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
284 do_facet client mkdir -p $DIR/$tdir
288 pgcache_empty || return 1
290 # shouldn't have to set stripe size of count==1
291 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
292 get_stripe_info client $f
293 if [ $stripe_index -ne 0 ]; then
295 error "$f: different stripe offset ($stripe_index)" && return
298 do_facet client cp $SAMPLE_FILE $f
303 df $MOUNT > /dev/null 2>&1
305 # my understanding is that there should be nothing in the page
306 # cache after the client reconnects?
308 pgcache_empty || rc=2
312 run_test 18b "eviction and reconnect clears page cache (2766)"
315 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
317 do_facet client mkdir -p $DIR/$tdir
321 pgcache_empty || return 1
323 # shouldn't have to set stripe size of count==1
324 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
325 get_stripe_info client $f
326 if [ $stripe_index -ne 0 ]; then
328 error "$f: different stripe offset ($stripe_index)" && return
331 do_facet client cp $SAMPLE_FILE $f
335 # OBD_FAIL_OST_CONNECT_NET2
336 # lost reply to connect request
337 do_facet ost1 lctl set_param fail_loc=0x80000225
339 df $MOUNT > /dev/null 2>&1
341 # my understanding is that there should be nothing in the page
342 # cache after the client reconnects?
344 pgcache_empty || rc=2
348 run_test 18c "Dropped connect reply after eviction handing (14755)"
352 do_facet client mcreate $f || return 1
353 drop_ldlm_cancel "chmod 0777 $f" || echo "evicted as expected"
355 do_facet client checkstat -v -p 0777 $f || echo evicted
356 # let the client reconnect
358 do_facet client "munlink $f"
360 run_test 19a "test expired_lock_main on mds (2867)"
364 do_facet client multiop $f Ow || return 1
365 do_facet client multiop $f or || return 2
369 do_facet client multiop $f or || return 3
370 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
372 do_facet client munlink $f || return 4
374 run_test 19b "test expired_lock_main on ost (2867)"
376 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
377 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
380 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
381 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
384 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
385 do_facet ost1 lctl set_param fail_loc=0x80000308
386 kill -USR1 $MULTI_PID
389 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
391 run_test 20a "ldlm_handle_enqueue error (should return error)"
393 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
394 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
397 lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
399 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
400 do_facet ost1 lctl set_param fail_loc=0x80000308
401 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
402 error "didn't fail open enqueue" || true
404 run_test 20b "ldlm_handle_enqueue error (should return error)"
407 # bug 19039 -- a race between ldlm_enqueue and lock
408 # destroying when the client export is disconnected
413 rm -f $DIR/$tdir/$tfile
414 # OBD_FAIL_LDLM_ENQUEUE_LOCAL 0x319
415 do_facet ost1 lctl set_param fail_loc=0x80000319
416 lfs setstripe -c 1 -o 0 $DIR/$tdir/$tfile
417 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M conv=notrunc count=1 &
423 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
427 run_test 20c "ldlm_lock_enqueue is called for a destroyed lock (shouldn't LBUG)"
430 mkdir -p $DIR/$tdir-1
431 mkdir -p $DIR/$tdir-2
432 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
435 do_facet mds "lctl set_param fail_loc=0x80000129"
436 multiop $DIR/$tdir-2/f Oc &
439 do_facet mds "lctl set_param fail_loc=0"
441 do_facet mds "lctl set_param fail_loc=0x80000115"
442 kill -USR1 $close_pid
444 wait $close_pid || return 1
445 wait $open_pid || return 2
446 do_facet mds "lctl set_param fail_loc=0"
448 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
449 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
453 run_test 21a "drop close request while close and open are both in flight"
456 mkdir -p $DIR/$tdir-1
457 mkdir -p $DIR/$tdir-2
458 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
461 do_facet mds "lctl set_param fail_loc=0x80000107"
462 mcreate $DIR/$tdir-2/f &
465 do_facet mds "lctl set_param fail_loc=0"
467 kill -USR1 $close_pid
469 wait $close_pid || return 1
470 wait $open_pid || return 3
472 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
473 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
476 run_test 21b "drop open request while close and open are both in flight"
479 mkdir -p $DIR/$tdir-1
480 mkdir -p $DIR/$tdir-2
481 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
484 do_facet mds "lctl set_param fail_loc=0x80000107"
485 mcreate $DIR/$tdir-2/f &
488 do_facet mds "lctl set_param fail_loc=0"
490 do_facet mds "lctl set_param fail_loc=0x80000115"
491 kill -USR1 $close_pid
493 wait $close_pid || return 1
494 wait $open_pid || return 2
496 do_facet mds "lctl set_param fail_loc=0"
498 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
499 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
502 run_test 21c "drop both request while close and open are both in flight"
505 mkdir -p $DIR/$tdir-1
506 mkdir -p $DIR/$tdir-2
507 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
510 do_facet mds "lctl set_param fail_loc=0x80000129"
511 multiop $DIR/$tdir-2/f Oc &
513 do_facet mds "lctl set_param fail_loc=0"
515 do_facet mds "lctl set_param fail_loc=0x80000122"
518 wait $pid || return 1
519 do_facet mds "lctl set_param fail_loc=0"
521 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
522 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
526 run_test 21d "drop close reply while close and open are both in flight"
529 mkdir -p $DIR/$tdir-1
530 mkdir -p $DIR/$tdir-2
531 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
534 do_facet mds "lctl set_param fail_loc=0x80000119"
535 touch $DIR/$tdir-2/f &
537 do_facet mds "lctl set_param fail_loc=0"
541 wait $pid || return 1
544 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
545 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
548 run_test 21e "drop open reply while close and open are both in flight"
551 mkdir -p $DIR/$tdir-1
552 mkdir -p $DIR/$tdir-2
553 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
556 do_facet mds "lctl set_param fail_loc=0x80000119"
557 touch $DIR/$tdir-2/f &
559 do_facet mds "lctl set_param fail_loc=0"
561 do_facet mds "lctl set_param fail_loc=0x80000122"
564 wait $pid || return 1
565 do_facet mds "lctl set_param fail_loc=0"
567 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
568 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
571 run_test 21f "drop both reply while close and open are both in flight"
574 mkdir -p $DIR/$tdir-1
575 mkdir -p $DIR/$tdir-2
576 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
579 do_facet mds "lctl set_param fail_loc=0x80000119"
580 touch $DIR/$tdir-2/f &
582 do_facet mds "lctl set_param fail_loc=0"
584 do_facet mds "lctl set_param fail_loc=0x80000115"
587 wait $pid || return 1
588 do_facet mds "lctl set_param fail_loc=0"
590 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
591 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
594 run_test 21g "drop open reply and close request while close and open are both in flight"
597 mkdir -p $DIR/$tdir-1
598 mkdir -p $DIR/$tdir-2
599 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
602 do_facet mds "lctl set_param fail_loc=0x80000107"
603 touch $DIR/$tdir-2/f &
606 do_facet mds "lctl set_param fail_loc=0"
608 do_facet mds "lctl set_param fail_loc=0x80000122"
611 wait $pid || return 1
612 do_facet mds "lctl set_param fail_loc=0"
614 wait $touch_pid || return 2
616 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
617 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
620 run_test 21h "drop open request and close reply while close and open are both in flight"
622 # bug 3462 - multiple MDC requests
627 do_facet mds "lctl set_param fail_loc=0x80000115"
632 multiop $f1 msu || return 1
635 do_facet mds "lctl set_param fail_loc=0"
637 wait $close_pid || return 2
638 rm -rf $f2 || return 4
640 run_test 22 "drop close request and do mknod"
643 multiop_bg_pause $DIR/$tfile O_c || return 1
645 # give a chance for open
649 drop_request "kill -USR1 $pid"
652 wait $pid || return 1
655 run_test 23 "client hang when close a file after mds crash"
657 test_24() { # bug 11710 details correct fsync() behavior
658 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
661 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
663 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
666 kill -USR1 $MULTI_PID
669 lctl set_param fail_loc=0x0
671 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
673 run_test 24 "fsync error (should return error)"
675 wait_client_evicted () {
678 local varsvc=${facet}_svc
680 wait_update $(facet_host $facet) "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" $((exports - 1)) $3
683 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
684 # this test can only run from a client on a separate node.
685 remote_ost || { skip "local OST" && return 0; }
686 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
687 remote_mds || { skip "local MDS" && return 0; }
689 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
690 skip "mgs and ost1 are at the same node"
694 check_timeout || return 1
696 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
698 echo starting with $OST_NEXP OST exports
699 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
700 do_facet client lctl set_param fail_loc=0x505
701 # evictor takes up to 2.25x to evict. But if there's a
702 # race to start the evictor from various obds, the loser
703 # might have to wait for the next ping.
706 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
708 do_facet client lctl set_param fail_loc=0x0
710 [ $rc -eq 0 ] || error "client not evicted from OST"
712 run_test 26a "evict dead exports"
714 test_26b() { # bug 10140 - evict dead exports by pinger
715 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
717 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
718 skip "mgs and ost1 are at the same node"
722 check_timeout || return 1
724 zconf_mount `hostname` $MOUNT2 ||
725 { error "Failed to mount $MOUNT2"; return 2; }
726 sleep 1 # wait connections being established
728 local dev=$(get_mds_mdt_device_proc_path)
729 local MDS_NEXP=$(do_facet mds lctl get_param -n $dev.${mds_svc}.num_exports | cut -d' ' -f2)
730 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
732 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
734 #force umount a client; exports should get evicted
735 zconf_umount `hostname` $MOUNT2 -f
737 # PING_INTERVAL max(obd_timeout / 4, 1U)
738 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
740 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
741 # But if there's a race to start the evictor from various obds,
742 # the loser might have to wait for the next ping.
743 # = 9 * PING_INTERVAL + PING_INTERVAL
744 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
745 # let's wait $((TIMEOUT * 3)) # bug 19887
747 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
748 error "Client was not evicted by ost" rc=1
749 wait_client_evicted mds $MDS_NEXP $((TIMEOUT * 3)) || \
750 error "Client was not evicted by mds"
752 run_test 26b "evict dead exports"
756 writemany -q -a $DIR/$tdir/$tfile 0 5 &
759 local save_FAILURE_MODE=$FAILURE_MODE
762 #define OBD_FAIL_OSC_SHUTDOWN 0x407
763 do_facet mds lctl set_param fail_loc=0x80000407
764 # need to wait for reconnect
765 echo -n waiting for fail_loc
766 while [ $(do_facet mds lctl get_param -n fail_loc) -eq -2147482617 ]; do
770 do_facet mds lctl get_param -n fail_loc
773 kill -USR1 $CLIENT_PID
776 FAILURE_MODE=$save_FAILURE_MODE
778 run_test 27 "fail LOV while using OSC's"
780 test_28() { # bug 6086 - error adding new clients
781 do_facet client mcreate $DIR/$tfile || return 1
782 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
783 #define OBD_FAIL_MDS_ADD_CLIENT 0x12f
784 do_facet mds lctl set_param fail_loc=0x8000012f
785 # fail once (evicted), reconnect fail (fail_loc), ok
786 client_up || client_up || client_up || error "reconnect failed"
788 fail mds # verify MDS last_rcvd can be loaded
790 run_test 28 "handle error adding new clients (bug 6086)"
795 lctl set_param debug="-dlmtrace -ha"
796 # put a load of file creates/writes/deletes
797 writemany -q $DIR/$tdir/$tfile 0 5 &
799 echo writemany pid $CLIENT_PID
802 $LCTL mark "$TESTNAME fail mds 1"
804 # wait for client to reconnect to MDS
806 $LCTL mark "$TESTNAME fail mds 2"
809 $LCTL mark "$TESTNAME fail mds 3"
811 # client process should see no problems even though MDS went down
813 kill -USR1 $CLIENT_PID
816 echo writemany returned $rc
817 #these may fail because of eviction due to slow AST response.
819 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
821 run_test 50 "failover MDS under load"
825 # put a load of file creates/writes/deletes
826 writemany -q $DIR/$tdir/$tfile 0 5 &
831 # failover at various points during recovery
832 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
833 echo will failover at $SEQ
836 echo failover in $i sec
838 $LCTL mark "$TESTNAME fail mds $i"
841 # client process should see no problems even though MDS went down
842 # and recovery was interrupted
844 kill -USR1 $CLIENT_PID
847 echo writemany returned $rc
848 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
850 run_test 51 "failover MDS during recovery"
853 do_facet client "mkdir -p $DIR/$tdir"
854 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
856 echo writemany pid $CLIENT_PID
859 $LCTL mark "$TESTNAME fail ost $1"
862 wait $CLIENT_PID || rc=$?
863 # active client process should see an EIO for down OST
864 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
865 # but timing or failover setup may allow success
866 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
867 echo "writemany returned $rc"
872 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
877 [ $rc -ne 0 ] && { return $rc; }
878 # wait for client to reconnect to OST
882 [ $rc -ne 0 ] && { return $rc; }
889 run_test 52 "failover OST under load"
891 # test of open reconstruct
894 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
897 run_test 53 "touch: drop rep"
900 zconf_mount `hostname` $MOUNT2
904 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
907 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
908 [ x"$ERROR" == x ] || error "back in time occured"
910 run_test 54 "back in time"
912 # bug 11330 - liblustre application death during I/O locks up OST
914 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
918 # first dd should be finished quickly
919 lfs setstripe $DIR/$tdir/$tfile-1 -c 1 -i 0
920 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
923 echo "step1: testing ......"
925 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
927 if [ $count -gt 64 ]; then
928 error "dd should be finished!"
932 echo "(dd_pid=$DDPID, time=$count)successful"
934 lfs setstripe $DIR/$tdir/$tfile-2 -c 1 -i 0
935 #define OBD_FAIL_OST_DROP_REQ 0x21d
936 do_facet ost1 lctl set_param fail_loc=0x0000021d
937 # second dd will be never finished
938 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
941 echo "step2: testing ......"
942 while [ $count -le 64 ]; do
943 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
944 if [ -z $dd_name ]; then
946 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
947 error "dd shouldn't be finished!"
952 echo "(dd_pid=$DDPID, time=$count)successful"
954 #Recover fail_loc and dd will finish soon
955 do_facet ost1 lctl set_param fail_loc=0
957 echo "step3: testing ......"
959 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
961 if [ $count -gt 500 ]; then
962 error "dd should be finished!"
966 echo "(dd_pid=$DDPID, time=$count)successful"
970 run_test 55 "ost_brw_read/write drops timed-out read/write request"
972 test_56() { # b=11277
973 #define OBD_FAIL_MDS_RESEND 0x136
975 do_facet mds lctl set_param fail_loc=0x80000136
977 do_facet mds lctl set_param fail_loc=0
980 run_test 56 "do not allow reconnect to busy exports"
983 # no oscs means no client or mdt
984 while lctl get_param osc.*.* > /dev/null 2>&1; do
985 : # loop until proc file is removed
989 test_57() { # bug 10866
993 #define OBD_FAIL_LPROC_REMOVE 0xB00
994 lctl set_param fail_loc=0x80000B00
995 zconf_umount `hostname` $DIR
996 lctl set_param fail_loc=0x80000B00
999 lctl set_param fail_loc=0
1001 do_facet client "df $DIR"
1003 run_test 57 "read procfs entries causes kernel crash"
1005 test_58() { # bug 11546
1006 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1009 lctl set_param fail_loc=0x80000801
1010 cp $DIR/$tfile /dev/null &
1013 lctl set_param fail_loc=0
1014 drop_bl_callback rm -f $DIR/$tfile
1016 do_facet client "df $DIR"
1018 run_test 58 "Eviction in the middle of open RPC reply processing"
1020 test_59() { # bug 10589
1021 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1022 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1023 lctl set_param fail_loc=0x311
1024 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1025 [ $? = 0 ] || error "dd write failed"
1026 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1027 lctl set_param fail_loc=0
1029 zconf_umount `hostname` $MOUNT2 -f
1030 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1031 [ $? = 0 ] || error "dd read failed"
1032 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1033 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1035 run_test 59 "Read cancel race on client eviction"
1040 local mdtosc=$(get_mdtosc_proc_path ${ost1_svc})
1041 local cflags=osc.$mdtosc.connect_flags
1042 do_facet mds "lctl get_param -n $cflags |grep -q skip_orphan"
1043 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1045 mkdir -p $DIR/d61 || error "mkdir dir $DIR/d61 failed"
1046 # Set the default stripe of $DIR/d61 to put the files to ost1
1047 $LFS setstripe -c 1 --index 0 $DIR/d61
1050 createmany -o $DIR/d61/$tfile-%d 10
1051 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1055 touch $DIR/d61/$tfile
1056 local id=`$LFS getstripe $DIR/d61/$tfile | awk '($1 ~ 0 && $2 ~ /^[1-9]+/) {print $2}'`
1057 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1062 run_test 61 "Verify to not reuse orphan objects - bug 17485"
1064 equals_msg `basename $0`: test complete, cleaning up
1065 check_and_cleanup_lustre
1066 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true