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 # also long tests: 19, 21a, 21e, 21f, 23, 27
17 # 1 2.5 2.5 4 4 (min)"
18 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
22 # Allow us to override the setup if we already have a mounted system by
23 # setting SETUP=" " and CLEANUP=" "
25 CLEANUP=${CLEANUP:-""}
27 check_and_setup_lustre
30 rm -rf $DIR/[df][0-9]*
33 drop_request "mcreate $DIR/f1" || return 1
34 drop_reint_reply "mcreate $DIR/f2" || return 2
36 run_test 1 "mcreate: drop req, drop rep"
39 drop_request "tchmod 111 $DIR/f2" || return 1
40 drop_reint_reply "tchmod 666 $DIR/f2" || return 2
42 run_test 2 "chmod: drop req, drop rep"
45 drop_request "statone $DIR/f2" || return 1
46 drop_reply "statone $DIR/f2" || return 2
48 run_test 3 "stat: drop req, drop rep"
50 SAMPLE_NAME=f0.recovery-small.junk
51 SAMPLE_FILE=$TMP/$SAMPLE_NAME
52 # make this big, else test 9 doesn't wait for bulk -- bz 5595
53 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
56 do_facet client "cp $SAMPLE_FILE $DIR/$SAMPLE_NAME" || return 1
57 drop_request "cat $DIR/$SAMPLE_NAME > /dev/null" || return 2
58 drop_reply "cat $DIR/$SAMPLE_NAME > /dev/null" || return 3
60 run_test 4 "open: drop req, drop rep"
62 RENAMED_AGAIN=$DIR/f0.renamed-again
65 drop_request "mv $DIR/$SAMPLE_NAME $DIR/$tfile-renamed" || return 1
66 drop_reint_reply "mv $DIR/$tfile-renamed $RENAMED_AGAIN" || return 2
67 do_facet client "checkstat -v $RENAMED_AGAIN" || return 3
69 run_test 5 "rename: drop req, drop rep"
71 [ ! -e $RENAMED_AGAIN ] && cp $SAMPLE_FILE $RENAMED_AGAIN
76 drop_request "mlink $RENAMED_AGAIN $LINK1" || return 1
77 drop_reint_reply "mlink $RENAMED_AGAIN $LINK2" || return 2
79 run_test 6 "link: drop req, drop rep"
81 [ ! -e $LINK1 ] && mlink $RENAMED_AGAIN $LINK1
82 [ ! -e $LINK2 ] && mlink $RENAMED_AGAIN $LINK2
84 drop_request "munlink $LINK1" || return 1
85 drop_reint_reply "munlink $LINK2" || return 2
87 run_test 7 "unlink: drop req, drop rep"
91 drop_reint_reply "touch $DIR/$tfile" || return 1
93 run_test 8 "touch: drop rep (bug 1423)"
95 SAMPLE_FILE=$TMP/recovery-small.junk
96 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
100 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
102 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
103 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
104 do_facet client "sync"
105 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
107 run_test 9 "pause bulk on OST (bug 1420)"
111 do_facet client mcreate $DIR/$tfile || return 1
112 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
113 # wait for the mds to evict the client
114 #echo "sleep $(($TIMEOUT*2))"
115 #sleep $(($TIMEOUT*2))
116 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
117 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
118 do_facet client "munlink $DIR/$tfile"
120 run_test 10 "finish request on server after client eviction (bug 1521)"
123 # wake up a thread waiting for completion after eviction
125 do_facet client multiop $DIR/$tfile Ow || return 1
126 do_facet client multiop $DIR/$tfile or || return 2
130 do_facet client multiop $DIR/$tfile or || return 3
131 drop_bl_callback multiop $DIR/$tfile Ow || echo "evicted as expected"
133 do_facet client munlink $DIR/$tfile || return 4
135 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
139 $LCTL mark multiop $DIR/$tfile OS_c
140 do_facet mds "lctl set_param fail_loc=0x115"
141 clear_failloc mds $((TIMEOUT * 2)) &
142 multiop_bg_pause $DIR/$tfile OS_c || return 1
144 #define OBD_FAIL_MDS_CLOSE_NET 0x115
146 echo "waiting for multiop $PID"
147 wait $PID || return 2
148 do_facet client munlink $DIR/$tfile || return 3
150 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
152 # Bug 113, check that readdir lost recv timeout works.
154 mkdir -p $DIR/$tdir || return 1
155 touch $DIR/$tdir/newentry || return
156 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
157 do_facet mds "lctl set_param fail_loc=0x80000104"
158 ls $DIR/$tdir || return 3
159 do_facet mds "lctl set_param fail_loc=0"
160 rm -rf $DIR/$tdir || return 4
162 run_test 13 "mdc_readpage restart test (bug 1138)"
164 # Bug 113, check that readdir lost send timeout works.
167 touch $DIR/$tdir/newentry
168 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
169 do_facet mds "lctl set_param fail_loc=0x80000106"
170 ls $DIR/$tdir || return 1
171 do_facet mds "lctl set_param fail_loc=0"
173 run_test 14 "mdc_readpage resend test (bug 1138)"
176 do_facet mds "lctl set_param fail_loc=0x80000128"
177 touch $DIR/$tfile && return 1
180 run_test 15 "failed open (-ENOMEM)"
182 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
184 lctl set_param -n llite.*.max_read_ahead_mb 0
188 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
192 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
194 do_facet client cp $SAMPLE_FILE $DIR
198 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
199 do_facet ost1 lctl set_param fail_loc=0x80000504
201 # OST bulk will time out here, client resends
202 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
203 do_facet ost1 lctl set_param fail_loc=0
204 # give recovery a chance to finish (shouldn't take long)
206 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
209 run_test 16 "timeout bulk put, don't evict client (2732)"
214 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
216 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
217 if at_is_enabled; then
218 at_max_saved=$(at_max_get ost1)
219 at_max_set $TIMEOUT ost1
222 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
223 # OST bulk will time out here, client retries
224 do_facet client lctl set_param fail_loc=0x80000503
225 # need to ensure we send an RPC
226 do_facet client cp $SAMPLE_FILE $DIR/$tfile
229 # with AT, client will wait adaptive_max*factor+net_latency before
230 # expiring the req, hopefully timeout*2 is enough
231 sleep $(($TIMEOUT*2))
233 do_facet ost1 lctl set_param fail_loc=0
234 do_facet client "df $DIR"
235 # expect cmp to succeed, client resent bulk
236 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
237 do_facet client "rm $DIR/$tfile" || return 4
238 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
241 run_test 17 "timeout bulk get, don't evict client (2732)"
244 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
246 do_facet client mkdir -p $DIR/$tdir
250 pgcache_empty || return 1
253 lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
254 get_stripe_info client $f
255 if [ $stripe_index -ne 1 ]; then
257 error "$f: different stripe offset ($stripe_index)" && return
260 do_facet client cp $SAMPLE_FILE $f
262 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | awk '{print $1}'`
263 $LCTL --device $osc2dev deactivate || return 3
264 # my understanding is that there should be nothing in the page
265 # cache after the client reconnects?
267 pgcache_empty || rc=2
268 $LCTL --device $osc2dev activate
272 run_test 18a "manual ost invalidate clears page cache immediately"
275 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
277 do_facet client mkdir -p $DIR/$tdir
281 pgcache_empty || return 1
283 # shouldn't have to set stripe size of count==1
284 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
285 get_stripe_info client $f
286 if [ $stripe_index -ne 0 ]; then
288 error "$f: different stripe offset ($stripe_index)" && return
291 do_facet client cp $SAMPLE_FILE $f
297 df $MOUNT > /dev/null 2>&1
299 # my understanding is that there should be nothing in the page
300 # cache after the client reconnects?
302 pgcache_empty || rc=2
306 run_test 18b "eviction and reconnect clears page cache (2766)"
309 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
311 do_facet client mkdir -p $DIR/$tdir
315 pgcache_empty || return 1
317 # shouldn't have to set stripe size of count==1
318 lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
319 get_stripe_info client $f
320 if [ $stripe_index -ne 0 ]; then
322 error "$f: different stripe offset ($stripe_index)" && return
325 do_facet client cp $SAMPLE_FILE $f
329 # OBD_FAIL_OST_CONNECT_NET2
330 # lost reply to connect request
331 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 # bug 19039 -- a race between ldlm_enqueue and lock
403 # destroying when the client export is disconnected
408 rm -f $DIR/$tdir/$tfile
409 # OBD_FAIL_LDLM_ENQUEUE_LOCAL 0x319
410 do_facet ost1 lctl set_param fail_loc=0x80000319
411 lfs setstripe -c 1 -o 0 $DIR/$tdir/$tfile
412 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M conv=notrunc count=1 &
418 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
422 run_test 20c "ldlm_lock_enqueue is called for a destroyed lock (shouldn't LBUG)"
425 mkdir -p $DIR/$tdir-1
426 mkdir -p $DIR/$tdir-2
427 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
430 do_facet mds "lctl set_param fail_loc=0x80000129"
431 multiop $DIR/$tdir-2/f Oc &
434 do_facet mds "lctl set_param fail_loc=0"
436 do_facet mds "lctl set_param fail_loc=0x80000115"
437 kill -USR1 $close_pid
439 wait $close_pid || return 1
440 wait $open_pid || return 2
441 do_facet mds "lctl set_param fail_loc=0"
443 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
444 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
448 run_test 21a "drop close 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 mds "lctl set_param fail_loc=0x80000107"
457 mcreate $DIR/$tdir-2/f &
460 do_facet mds "lctl set_param fail_loc=0"
462 kill -USR1 $close_pid
464 wait $close_pid || return 1
465 wait $open_pid || return 3
467 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
468 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
471 run_test 21b "drop open request while close and open are both in flight"
474 mkdir -p $DIR/$tdir-1
475 mkdir -p $DIR/$tdir-2
476 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
479 do_facet mds "lctl set_param fail_loc=0x80000107"
480 mcreate $DIR/$tdir-2/f &
483 do_facet mds "lctl set_param fail_loc=0"
485 do_facet mds "lctl set_param fail_loc=0x80000115"
486 kill -USR1 $close_pid
488 wait $close_pid || return 1
489 wait $open_pid || return 2
491 do_facet mds "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
497 run_test 21c "drop both request while close and open are both in flight"
500 mkdir -p $DIR/$tdir-1
501 mkdir -p $DIR/$tdir-2
502 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
505 do_facet mds "lctl set_param fail_loc=0x80000129"
506 multiop $DIR/$tdir-2/f Oc &
508 do_facet mds "lctl set_param fail_loc=0"
510 do_facet mds "lctl set_param fail_loc=0x80000122"
513 wait $pid || return 1
514 do_facet mds "lctl set_param fail_loc=0"
516 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
517 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
521 run_test 21d "drop close 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 mds "lctl set_param fail_loc=0x80000119"
530 touch $DIR/$tdir-2/f &
532 do_facet mds "lctl set_param fail_loc=0"
536 wait $pid || return 1
539 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
540 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
543 run_test 21e "drop open 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 mds "lctl set_param fail_loc=0x80000119"
552 touch $DIR/$tdir-2/f &
554 do_facet mds "lctl set_param fail_loc=0"
556 do_facet mds "lctl set_param fail_loc=0x80000122"
559 wait $pid || return 1
560 do_facet mds "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 21f "drop both reply 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 mds "lctl set_param fail_loc=0x80000119"
575 touch $DIR/$tdir-2/f &
577 do_facet mds "lctl set_param fail_loc=0"
579 do_facet mds "lctl set_param fail_loc=0x80000115"
582 wait $pid || return 1
583 do_facet mds "lctl set_param fail_loc=0"
585 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
586 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
589 run_test 21g "drop open reply and close request while close and open are both in flight"
592 mkdir -p $DIR/$tdir-1
593 mkdir -p $DIR/$tdir-2
594 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
597 do_facet mds "lctl set_param fail_loc=0x80000107"
598 touch $DIR/$tdir-2/f &
601 do_facet mds "lctl set_param fail_loc=0"
603 do_facet mds "lctl set_param fail_loc=0x80000122"
606 wait $pid || return 1
607 do_facet mds "lctl set_param fail_loc=0"
609 wait $touch_pid || return 2
611 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
612 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
615 run_test 21h "drop open request and close reply while close and open are both in flight"
617 # bug 3462 - multiple MDC requests
622 do_facet mds "lctl set_param fail_loc=0x80000115"
627 multiop $f1 msu || return 1
630 do_facet mds "lctl set_param fail_loc=0"
632 wait $close_pid || return 2
633 rm -rf $f2 || return 4
635 run_test 22 "drop close request and do mknod"
638 multiop_bg_pause $DIR/$tfile O_c || return 1
640 # give a chance for open
644 drop_request "kill -USR1 $pid"
647 wait $pid || return 1
650 run_test 23 "client hang when close a file after mds crash"
652 test_24() { # bug 11710 details correct fsync() behavior
653 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
656 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
658 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
661 kill -USR1 $MULTI_PID
664 lctl set_param fail_loc=0x0
666 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
668 run_test 24 "fsync error (should return error)"
670 wait_client_evicted () {
673 local varsvc=${facet}_svc
675 wait_update $(facet_host $facet) "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" $((exports - 1)) $3
678 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
679 # this test can only run from a client on a separate node.
680 remote_ost || { skip "local OST" && return 0; }
681 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
682 remote_mds || { skip "local MDS" && return 0; }
684 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
685 skip "mgs and ost1 are at the same node"
689 check_timeout || return 1
691 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
693 echo starting with $OST_NEXP OST exports
694 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
695 do_facet client lctl set_param fail_loc=0x505
696 # evictor takes up to 2.25x to evict. But if there's a
697 # race to start the evictor from various obds, the loser
698 # might have to wait for the next ping.
701 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
703 do_facet client lctl set_param fail_loc=0x0
705 [ $rc -eq 0 ] || error "client not evicted from OST"
707 run_test 26a "evict dead exports"
709 test_26b() { # bug 10140 - evict dead exports by pinger
710 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
712 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
713 skip "mgs and ost1 are at the same node"
717 check_timeout || return 1
719 zconf_mount `hostname` $MOUNT2 ||
720 { error "Failed to mount $MOUNT2"; return 2; }
721 sleep 1 # wait connections being established
723 local dev=$(get_mds_mdt_device_proc_path)
724 local MDS_NEXP=$(do_facet mds lctl get_param -n $dev.${mds_svc}.num_exports | cut -d' ' -f2)
725 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
727 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
729 #force umount a client; exports should get evicted
730 zconf_umount `hostname` $MOUNT2 -f
732 # PING_INTERVAL max(obd_timeout / 4, 1U)
733 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
735 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
736 # But if there's a race to start the evictor from various obds,
737 # the loser might have to wait for the next ping.
738 # = 9 * PING_INTERVAL + PING_INTERVAL
739 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
740 # let's wait $((TIMEOUT * 3)) # bug 19887
742 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
743 error "Client was not evicted by ost" rc=1
744 wait_client_evicted mds $MDS_NEXP $((TIMEOUT * 3)) || \
745 error "Client was not evicted by mds"
747 run_test 26b "evict dead exports"
751 writemany -q -a $DIR/$tdir/$tfile 0 5 &
754 local save_FAILURE_MODE=$FAILURE_MODE
757 #define OBD_FAIL_OSC_SHUTDOWN 0x407
758 do_facet mds lctl set_param fail_loc=0x80000407
759 # need to wait for reconnect
760 echo waiting for fail_loc
761 wait_update_facet mds "lctl get_param -n fail_loc" "-2147482617"
764 kill -USR1 $CLIENT_PID
767 FAILURE_MODE=$save_FAILURE_MODE
769 run_test 27 "fail LOV while using OSC's"
771 test_28() { # bug 6086 - error adding new clients
772 do_facet client mcreate $DIR/$tfile || return 1
773 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
774 #define OBD_FAIL_MDS_ADD_CLIENT 0x12f
775 do_facet mds lctl set_param fail_loc=0x8000012f
776 # fail once (evicted), reconnect fail (fail_loc), ok
777 client_up || client_up || client_up || error "reconnect failed"
779 fail mds # verify MDS last_rcvd can be loaded
781 run_test 28 "handle error adding new clients (bug 6086)"
786 lctl set_param debug="-dlmtrace -ha"
787 # put a load of file creates/writes/deletes
788 writemany -q $DIR/$tdir/$tfile 0 5 &
790 echo writemany pid $CLIENT_PID
793 $LCTL mark "$TESTNAME fail mds 1"
795 # wait for client to reconnect to MDS
797 $LCTL mark "$TESTNAME fail mds 2"
800 $LCTL mark "$TESTNAME fail mds 3"
802 # client process should see no problems even though MDS went down
804 kill -USR1 $CLIENT_PID
807 echo writemany returned $rc
808 #these may fail because of eviction due to slow AST response.
810 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
812 run_test 50 "failover MDS under load"
816 # put a load of file creates/writes/deletes
817 writemany -q $DIR/$tdir/$tfile 0 5 &
822 # failover at various points during recovery
823 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
824 echo will failover at $SEQ
827 echo failover in $i sec
829 $LCTL mark "$TESTNAME fail mds $i"
832 # client process should see no problems even though MDS went down
833 # and recovery was interrupted
835 kill -USR1 $CLIENT_PID
838 echo writemany returned $rc
839 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
841 run_test 51 "failover MDS during recovery"
844 do_facet client "mkdir -p $DIR/$tdir"
845 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
847 echo writemany pid $CLIENT_PID
850 $LCTL mark "$TESTNAME fail ost $1"
853 wait $CLIENT_PID || rc=$?
854 # active client process should see an EIO for down OST
855 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
856 # but timing or failover setup may allow success
857 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
858 echo "writemany returned $rc"
863 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
868 [ $rc -ne 0 ] && { return $rc; }
869 # wait for client to reconnect to OST
873 [ $rc -ne 0 ] && { return $rc; }
880 run_test 52 "failover OST under load"
882 # test of open reconstruct
885 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
888 run_test 53 "touch: drop rep"
891 zconf_mount `hostname` $MOUNT2
895 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
898 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
899 [ x"$ERROR" == x ] || error "back in time occured"
901 run_test 54 "back in time"
903 # bug 11330 - liblustre application death during I/O locks up OST
905 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
909 # first dd should be finished quickly
910 lfs setstripe $DIR/$tdir/$tfile-1 -c 1 -i 0
911 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
914 echo "step1: testing ......"
916 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
918 if [ $count -gt 64 ]; then
919 error "dd should be finished!"
923 echo "(dd_pid=$DDPID, time=$count)successful"
925 lfs setstripe $DIR/$tdir/$tfile-2 -c 1 -i 0
926 #define OBD_FAIL_OST_DROP_REQ 0x21d
927 do_facet ost1 lctl set_param fail_loc=0x0000021d
928 # second dd will be never finished
929 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
932 echo "step2: testing ......"
933 while [ $count -le 64 ]; do
934 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
935 if [ -z $dd_name ]; then
937 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
938 error "dd shouldn't be finished!"
943 echo "(dd_pid=$DDPID, time=$count)successful"
945 #Recover fail_loc and dd will finish soon
946 do_facet ost1 lctl set_param fail_loc=0
948 echo "step3: testing ......"
950 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
952 if [ $count -gt 500 ]; then
953 error "dd should be finished!"
957 echo "(dd_pid=$DDPID, time=$count)successful"
961 run_test 55 "ost_brw_read/write drops timed-out read/write request"
963 test_56() { # b=11277
964 #define OBD_FAIL_MDS_RESEND 0x136
966 do_facet mds lctl set_param fail_loc=0x80000136
968 do_facet mds lctl set_param fail_loc=0
971 run_test 56 "do not allow reconnect to busy exports"
974 # no oscs means no client or mdt
975 while lctl get_param osc.*.* > /dev/null 2>&1; do
976 : # loop until proc file is removed
980 test_57() { # bug 10866
984 #define OBD_FAIL_LPROC_REMOVE 0xB00
985 lctl set_param fail_loc=0x80000B00
986 zconf_umount `hostname` $DIR
987 lctl set_param fail_loc=0x80000B00
990 lctl set_param fail_loc=0
992 do_facet client "df $DIR"
994 run_test 57 "read procfs entries causes kernel crash"
996 test_58() { # bug 11546
997 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1000 lctl set_param fail_loc=0x80000801
1001 cp $DIR/$tfile /dev/null &
1004 lctl set_param fail_loc=0
1005 drop_bl_callback rm -f $DIR/$tfile
1007 do_facet client "df $DIR"
1009 run_test 58 "Eviction in the middle of open RPC reply processing"
1011 test_59() { # bug 10589
1012 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1013 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1014 lctl set_param fail_loc=0x311
1015 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1016 [ $? = 0 ] || error "dd write failed"
1017 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1018 lctl set_param fail_loc=0
1020 zconf_umount `hostname` $MOUNT2 -f
1021 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1022 [ $? = 0 ] || error "dd read failed"
1023 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1024 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1026 run_test 59 "Read cancel race on client eviction"
1031 local mdtosc=$(get_mdtosc_proc_path ${ost1_svc})
1032 local cflags=osc.$mdtosc.connect_flags
1033 do_facet mds "lctl get_param -n $cflags |grep -q skip_orphan"
1034 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1036 mkdir -p $DIR/d61 || error "mkdir dir $DIR/d61 failed"
1037 # Set the default stripe of $DIR/d61 to put the files to ost1
1038 $LFS setstripe -c 1 --index 0 $DIR/d61
1041 createmany -o $DIR/d61/$tfile-%d 10
1042 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1046 touch $DIR/d61/$tfile
1047 local id=`$LFS getstripe $DIR/d61/$tfile | awk '($1 ~ 0 && $2 ~ /^[1-9]+/) {print $2}'`
1048 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1053 run_test 61 "Verify to not reuse orphan objects - bug 17485"
1055 equals_msg `basename $0`: test complete, cleaning up
1056 check_and_cleanup_lustre
1057 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true