6 ALWAYS_EXCEPT="24 52 $RECOVERY_SMALL_EXCEPT"
8 export MULTIOP=${MULTIOP:-multiop}
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 require_dsh_mds || exit 0
18 # also long tests: 19, 21a, 21e, 21f, 23, 27
19 # 1 2.5 2.5 4 4 (min)"
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
24 # Allow us to override the setup if we already have a mounted system by
25 # setting SETUP=" " and CLEANUP=" "
27 CLEANUP=${CLEANUP:-""}
29 check_and_setup_lustre
32 rm -rf $DIR/[df][0-9]*
35 local f1="$DIR/$tfile"
36 local f2="$DIR/$tfile.2"
38 drop_request "mcreate $f1" ||
39 error_noexit "create '$f1': drop req"
41 drop_reint_reply "mcreate $f2" ||
42 error_noexit "create '$f2': drop rep"
44 drop_request "tchmod 111 $f2" ||
45 error_noexit "chmod '$f2': drop req"
47 drop_reint_reply "tchmod 666 $f2" ||
48 error_noexit "chmod '$f2': drop rep"
50 drop_request "statone $f2" ||
51 error_noexit "stat '$f2': drop req"
53 drop_reply "statone $f2" ||
54 error_noexit "stat '$f2': drop rep"
56 run_test 1 "create, chmod, stat: drop req, drop rep"
60 do_facet_create_file client $t 10K ||
61 error_noexit "Create file $t"
63 drop_request "cat $t > /dev/null" ||
64 error_noexit "Open request for $t file"
66 drop_reply "cat $t > /dev/null" ||
67 error_noexit "Open replay for $t file"
69 run_test 4 "open: drop req, drop rep"
74 local RR="$T-renamed-again"
75 do_facet_create_file client $T 10K ||
76 error_noexit "Create file $T"
78 drop_request "mv $T $R" ||
79 error_noexit "Rename $T"
81 drop_reint_reply "mv $R $RR" ||
82 error_noexit "Failed rename replay on $R"
84 do_facet client "checkstat -v $RR" ||
85 error_noexit "checkstat error on $RR"
87 do_facet client "rm $RR" ||
88 error_noexit "Can't remove file $RR"
90 run_test 5 "rename: drop req, drop rep"
94 local LINK1=$DIR/$tfile.link1
95 local LINK2=$DIR/$tfile.link2
97 do_facet_create_file client $T 10K ||
98 error_noexit "Create file $T"
100 drop_request "mlink $T $LINK1" ||
101 error_noexit "mlink request for $T"
103 drop_reint_reply "mlink $T $LINK2" ||
104 error_noexit "mlink reply for $T"
106 drop_request "munlink $LINK1" ||
107 error_noexit "munlink request for $T"
109 drop_reint_reply "munlink $LINK2" ||
110 error_noexit "munlink reply for $T"
112 do_facet client "rm $T" ||
113 error_noexit "Can't remove file $T"
115 run_test 6 "link, unlink: drop req, drop rep"
119 drop_reint_reply "touch $DIR/$tfile" || return 1
121 run_test 8 "touch: drop rep (bug 1423)"
125 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
129 do_facet_random_file client $TMP/$tfile 1K ||
130 error_noexit "Create random file $TMP/$tfile"
131 # make this big, else test 9 doesn't wait for bulk -- bz 5595
132 do_facet_create_file client $TMP/$t1 4M ||
133 error_noexit "Create file $TMP/$t1"
134 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
135 error_noexit "Can't copy to $DIR/$t1 file"
136 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
137 error_noexit "Can't pause_bulk copy"
138 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
139 error_noexit "Can't copy file"
140 do_facet client "sync"
141 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
142 error_noexit "Can't remove files"
143 do_facet client "rm $TMP/$t1 $TMP/$tfile"
145 run_test 9 "pause bulk on OST (bug 1420)"
149 do_facet client mcreate $DIR/$tfile || return 1
150 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
151 # wait for the mds to evict the client
152 #echo "sleep $(($TIMEOUT*2))"
153 #sleep $(($TIMEOUT*2))
154 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
155 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
156 do_facet client "munlink $DIR/$tfile"
158 run_test 10 "finish request on server after client eviction (bug 1521)"
161 # wake up a thread waiting for completion after eviction
163 do_facet client $MULTIOP $DIR/$tfile Ow || return 1
164 do_facet client $MULTIOP $DIR/$tfile or || return 2
168 do_facet client $MULTIOP $DIR/$tfile or || return 3
169 drop_bl_callback $MULTIOP $DIR/$tfile Ow || echo "evicted as expected"
171 do_facet client munlink $DIR/$tfile || return 4
173 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
177 $LCTL mark $MULTIOP $DIR/$tfile OS_c
178 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
179 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
180 multiop_bg_pause $DIR/$tfile OS_c || return 1
182 #define OBD_FAIL_MDS_CLOSE_NET 0x115
184 echo "waiting for multiop $PID"
185 wait $PID || return 2
186 do_facet client munlink $DIR/$tfile || return 3
188 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
190 # Bug 113, check that readdir lost recv timeout works.
192 mkdir -p $DIR/$tdir || return 1
193 touch $DIR/$tdir/newentry || return
194 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
195 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
196 ls $DIR/$tdir || return 3
197 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
198 rm -rf $DIR/$tdir || return 4
200 run_test 13 "mdc_readpage restart test (bug 1138)"
202 # Bug 113, check that readdir lost send timeout works.
205 touch $DIR/$tdir/newentry
206 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
207 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
208 ls $DIR/$tdir || return 1
209 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
211 run_test 14 "mdc_readpage resend test (bug 1138)"
214 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
215 touch $DIR/$tfile && return 1
218 run_test 15 "failed open (-ENOMEM)"
220 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
222 lctl set_param -n llite.*.max_read_ahead_mb 0
226 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
230 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
232 do_facet_random_file client $TMP/$tfile 100K ||
233 { error_noexit "Create random file $TMP/$T" ; return 0; }
234 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
235 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
239 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
240 do_facet ost1 "lctl set_param fail_loc=0x80000504"
242 # OST bulk will time out here, client resends
243 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
244 do_facet ost1 lctl set_param fail_loc=0
245 # give recovery a chance to finish (shouldn't take long)
247 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
250 run_test 16 "timeout bulk put, don't evict client (2732)"
255 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
257 local SAMPLE_FILE=$TMP/$tfile
258 do_facet_random_file client $SAMPLE_FILE 20K ||
259 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
261 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
262 if at_is_enabled; then
263 at_max_saved=$(at_max_get ost1)
264 at_max_set $TIMEOUT ost1
267 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
268 # OST bulk will time out here, client retries
269 do_facet ost1 lctl set_param fail_loc=0x80000503
270 # need to ensure we send an RPC
271 do_facet client cp $SAMPLE_FILE $DIR/$tfile
274 # with AT, client will wait adaptive_max*factor+net_latency before
275 # expiring the req, hopefully timeout*2 is enough
276 sleep $(($TIMEOUT*2))
278 do_facet ost1 lctl set_param fail_loc=0
279 do_facet client "df $DIR"
280 # expect cmp to succeed, client resent bulk
281 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
282 do_facet client "rm $DIR/$tfile" || return 4
283 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
286 run_test 17 "timeout bulk get, don't evict client (2732)"
289 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
291 do_facet_create_file client $TMP/$tfile 20K ||
292 { error_noexit "Create file $TMP/$tfile" ; return 0; }
294 do_facet client mkdir -p $DIR/$tdir
298 pgcache_empty || return 1
301 $LFS setstripe -i 1 -c 1 $f
302 stripe_index=$($LFS getstripe -i $f)
303 if [ $stripe_index -ne 1 ]; then
305 error "$f: stripe_index $stripe_index != 1" && return
308 do_facet client cp $TMP/$tfile $f
310 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
311 $LCTL --device $osc2dev deactivate || return 3
312 # my understanding is that there should be nothing in the page
313 # cache after the client reconnects?
315 pgcache_empty || rc=2
316 $LCTL --device $osc2dev activate
320 run_test 18a "manual ost invalidate clears page cache immediately"
323 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
325 do_facet_create_file client $TMP/$tfile 20K ||
326 { error_noexit "Create file $TMP/$tfile" ; return 0; }
328 do_facet client mkdir -p $DIR/$tdir
332 pgcache_empty || return 1
334 $LFS setstripe -i 0 -c 1 $f
335 stripe_index=$($LFS getstripe -i $f)
336 if [ $stripe_index -ne 0 ]; then
338 error "$f: stripe_index $stripe_index != 0" && return
341 do_facet client cp $TMP/$tfile $f
344 # allow recovery to complete
345 sleep $((TIMEOUT + 2))
346 # my understanding is that there should be nothing in the page
347 # cache after the client reconnects?
349 pgcache_empty || rc=2
353 run_test 18b "eviction and reconnect clears page cache (2766)"
356 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
358 do_facet_create_file client $TMP/$tfile 20K ||
359 { error_noexit "Create file $TMP/$tfile" ; return 0; }
361 do_facet client mkdir -p $DIR/$tdir
365 pgcache_empty || return 1
367 $LFS setstripe -i 0 -c 1 $f
368 stripe_index=$($LFS getstripe -i $f)
369 if [ $stripe_index -ne 0 ]; then
371 error "$f: stripe_index $stripe_index != 0" && return
374 do_facet client cp $TMP/$tfile $f
378 # OBD_FAIL_OST_CONNECT_NET2
379 # lost reply to connect request
380 do_facet ost1 lctl set_param fail_loc=0x80000225
383 df $MOUNT > /dev/null 2>&1
385 # my understanding is that there should be nothing in the page
386 # cache after the client reconnects?
388 pgcache_empty || rc=2
392 run_test 18c "Dropped connect reply after eviction handing (14755)"
395 local BEFORE=`date +%s`
400 do_facet client mcreate $DIR/$tfile || return 1
401 drop_ldlm_cancel "chmod 0777 $DIR2"
404 do_facet client "munlink $DIR/$tfile"
406 # let the client reconnect
408 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state | \
409 awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
411 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] || error "no eviction"
413 run_test 19a "test expired_lock_main on mds (2867)"
416 local BEFORE=`date +%s`
421 do_facet client $MULTIOP $DIR/$tfile Ow || return 1
422 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow
424 do_facet client munlink $DIR/$tfile
426 # let the client reconnect
428 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state | \
429 awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
431 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] || error "no eviction"
433 run_test 19b "test expired_lock_main on ost (2867)"
435 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
436 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
439 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
440 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
443 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
444 do_facet ost1 lctl set_param fail_loc=0x80000308
445 kill -USR1 $MULTI_PID
448 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
450 run_test 20a "ldlm_handle_enqueue error (should return error)"
452 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
453 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
456 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
458 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
459 do_facet ost1 lctl set_param fail_loc=0x80000308
460 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
461 error "didn't fail open enqueue" || true
463 run_test 20b "ldlm_handle_enqueue error (should return error)"
466 mkdir -p $DIR/$tdir-1
467 mkdir -p $DIR/$tdir-2
468 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
471 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
472 $MULTIOP $DIR/$tdir-2/f Oc &
475 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
477 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
478 kill -USR1 $close_pid
480 wait $close_pid || return 1
481 wait $open_pid || return 2
482 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
484 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
485 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
489 run_test 21a "drop close request while close and open are both in flight"
492 mkdir -p $DIR/$tdir-1
493 mkdir -p $DIR/$tdir-2
494 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
498 mcreate $DIR/$tdir-2/f &
501 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
503 kill -USR1 $close_pid
505 wait $close_pid || return 1
506 wait $open_pid || return 3
508 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
509 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
512 run_test 21b "drop open request while close and open are both in flight"
515 mkdir -p $DIR/$tdir-1
516 mkdir -p $DIR/$tdir-2
517 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
520 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
521 mcreate $DIR/$tdir-2/f &
524 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
526 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
527 kill -USR1 $close_pid
529 wait $close_pid || return 1
530 wait $open_pid || return 2
532 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
534 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
535 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
538 run_test 21c "drop both request while close and open are both in flight"
541 mkdir -p $DIR/$tdir-1
542 mkdir -p $DIR/$tdir-2
543 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
546 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
547 $MULTIOP $DIR/$tdir-2/f Oc &
549 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
551 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
554 wait $pid || return 1
555 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
557 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
558 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
562 run_test 21d "drop close reply while close and open are both in flight"
565 mkdir -p $DIR/$tdir-1
566 mkdir -p $DIR/$tdir-2
567 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
570 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
571 touch $DIR/$tdir-2/f &
573 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
577 wait $pid || return 1
580 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
581 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
584 run_test 21e "drop open reply while close and open are both in flight"
587 mkdir -p $DIR/$tdir-1
588 mkdir -p $DIR/$tdir-2
589 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
592 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
593 touch $DIR/$tdir-2/f &
595 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
597 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
600 wait $pid || return 1
601 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
603 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
604 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
607 run_test 21f "drop both reply while close and open are both in flight"
610 mkdir -p $DIR/$tdir-1
611 mkdir -p $DIR/$tdir-2
612 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
615 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
616 touch $DIR/$tdir-2/f &
618 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
620 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
623 wait $pid || return 1
624 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
626 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
627 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
630 run_test 21g "drop open reply and close request while close and open are both in flight"
633 mkdir -p $DIR/$tdir-1
634 mkdir -p $DIR/$tdir-2
635 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
638 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
639 touch $DIR/$tdir-2/f &
642 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
644 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
647 wait $pid || return 1
648 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
650 wait $touch_pid || return 2
652 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
653 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
656 run_test 21h "drop open request and close reply while close and open are both in flight"
658 # bug 3462 - multiple MDC requests
663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
668 $MULTIOP $f1 msu || return 1
671 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
673 wait $close_pid || return 2
674 rm -rf $f2 || return 4
676 run_test 22 "drop close request and do mknod"
679 multiop_bg_pause $DIR/$tfile O_c || return 1
681 # give a chance for open
685 drop_request "kill -USR1 $pid"
688 wait $pid || return 1
691 run_test 23 "client hang when close a file after mds crash"
693 test_24() { # bug 11710 details correct fsync() behavior
694 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
697 $LFS setstripe -i 0 -c 1 $DIR/$tdir
699 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
702 kill -USR1 $MULTI_PID
705 lctl set_param fail_loc=0x0
707 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
709 run_test 24 "fsync error (should return error)"
711 wait_client_evicted () {
714 local varsvc=${facet}_svc
716 wait_update $(facet_active_host $facet) \
717 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
721 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
722 # this test can only run from a client on a separate node.
723 remote_ost || { skip "local OST" && return 0; }
724 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
725 remote_mds || { skip "local MDS" && return 0; }
727 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
728 skip "msg and ost1 are at the same node"
732 check_timeout || return 1
734 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
736 echo starting with $OST_NEXP OST exports
737 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
738 do_facet client lctl set_param fail_loc=0x505
739 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
740 # But if there's a race to start the evictor from various obds,
741 # the loser might have to wait for the next ping.
744 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
746 do_facet client lctl set_param fail_loc=0x0
747 [ $rc -eq 0 ] || error "client not evicted from OST"
749 run_test 26a "evict dead exports"
751 test_26b() { # bug 10140 - evict dead exports by pinger
752 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
754 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
755 skip "msg and ost1 are at the same node"
759 check_timeout || return 1
761 zconf_mount `hostname` $MOUNT2 ||
762 { error "Failed to mount $MOUNT2"; return 2; }
763 sleep 1 # wait connections being established
765 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
766 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
768 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
770 zconf_umount `hostname` $MOUNT2 -f
772 # PING_INTERVAL max(obd_timeout / 4, 1U)
773 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
775 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
776 # But if there's a race to start the evictor from various obds,
777 # the loser might have to wait for the next ping.
778 # = 9 * PING_INTERVAL + PING_INTERVAL
779 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
780 # let's wait $((TIMEOUT * 3)) # bug 19887
782 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
783 error "Client was not evicted by ost" rc=1
784 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
785 error "Client was not evicted by mds"
787 run_test 26b "evict dead exports"
791 writemany -q -a $DIR/$tdir/$tfile 0 5 &
794 local save_FAILURE_MODE=$FAILURE_MODE
796 facet_failover $SINGLEMDS
797 #define OBD_FAIL_OSC_SHUTDOWN 0x407
798 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
799 # need to wait for reconnect
800 echo waiting for fail_loc
801 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
802 facet_failover $SINGLEMDS
804 kill -USR1 $CLIENT_PID
807 FAILURE_MODE=$save_FAILURE_MODE
809 run_test 27 "fail LOV while using OSC's"
811 test_28() { # bug 6086 - error adding new clients
812 do_facet client mcreate $DIR/$tfile || return 1
813 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
814 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
815 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
816 # fail once (evicted), reconnect fail (fail_loc), ok
817 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
819 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
821 run_test 28 "handle error adding new clients (bug 6086)"
823 test_29a() { # bug 22273 - error adding new clients
824 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
825 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
826 # fail abort so client will be new again
827 fail_abort $SINGLEMDS
828 client_up || error "reconnect failed"
831 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
833 test_29b() { # bug 22273 - error adding new clients
834 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
835 do_facet ost1 "lctl set_param fail_loc=0x80000711"
836 # fail abort so client will be new again
838 client_up || error "reconnect failed"
841 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
845 # put a load of file creates/writes/deletes
846 writemany -q $DIR/$tdir/$tfile 0 5 &
848 echo writemany pid $CLIENT_PID
852 # wait for client to reconnect to MDS
857 # client process should see no problems even though MDS went down
859 kill -USR1 $CLIENT_PID
862 echo writemany returned $rc
863 #these may fail because of eviction due to slow AST response.
864 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
866 run_test 50 "failover MDS under load"
869 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
870 do_facet ost1 lctl set_param fail_loc=0x00001310
873 # put a load of file creates/writes/deletes
874 writemany -q $DIR/$tdir/$tfile 0 5 &
878 facet_failover $SINGLEMDS
879 # failover at various points during recovery
880 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
881 echo will failover at $SEQ
884 echo failover in $i sec
886 facet_failover $SINGLEMDS
888 # client process should see no problems even though MDS went down
889 # and recovery was interrupted
891 kill -USR1 $CLIENT_PID
894 echo writemany returned $rc
895 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
897 run_test 51 "failover MDS during recovery"
900 do_facet client "mkdir -p $DIR/$tdir"
901 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
903 echo writemany pid $CLIENT_PID
908 wait $CLIENT_PID || rc=$?
909 # active client process should see an EIO for down OST
910 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
911 # but timing or failover setup may allow success
912 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
913 echo "writemany returned $rc"
918 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
923 [ $rc -ne 0 ] && { return $rc; }
924 # wait for client to reconnect to OST
928 [ $rc -ne 0 ] && { return $rc; }
935 run_test 52 "failover OST under load"
937 # test of open reconstruct
940 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
943 run_test 53 "touch: drop rep"
946 zconf_mount `hostname` $MOUNT2
950 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
953 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
954 [ x"$ERROR" == x ] || error "back in time occured"
956 run_test 54 "back in time"
958 # bug 11330 - liblustre application death during I/O locks up OST
960 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
964 # first dd should be finished quickly
965 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
966 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
969 echo "step1: testing ......"
971 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
973 if [ $count -gt 64 ]; then
974 error "dd should be finished!"
978 echo "(dd_pid=$DDPID, time=$count)successful"
980 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
981 #define OBD_FAIL_OST_DROP_REQ 0x21d
982 do_facet ost1 lctl set_param fail_loc=0x0000021d
983 # second dd will be never finished
984 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
987 echo "step2: testing ......"
988 while [ $count -le 64 ]; do
989 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
990 if [ -z $dd_name ]; then
992 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
993 error "dd shouldn't be finished!"
998 echo "(dd_pid=$DDPID, time=$count)successful"
1000 #Recover fail_loc and dd will finish soon
1001 do_facet ost1 lctl set_param fail_loc=0
1003 echo "step3: testing ......"
1005 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
1007 if [ $count -gt 500 ]; then
1008 error "dd should be finished!"
1012 echo "(dd_pid=$DDPID, time=$count)successful"
1016 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1018 test_56() { # b=11277
1019 #define OBD_FAIL_MDS_RESEND 0x136
1021 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1023 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1026 run_test 56 "do not allow reconnect to busy exports"
1029 # no oscs means no client or mdt
1030 while lctl get_param osc.*.* > /dev/null 2>&1; do
1031 : # loop until proc file is removed
1035 test_57() { # bug 10866
1039 #define OBD_FAIL_LPROC_REMOVE 0xB00
1040 lctl set_param fail_loc=0x80000B00
1041 zconf_umount `hostname` $DIR
1042 lctl set_param fail_loc=0x80000B00
1043 fail_abort $SINGLEMDS
1045 lctl set_param fail_loc=0
1047 do_facet client "df $DIR"
1049 run_test 57 "read procfs entries causes kernel crash"
1051 test_58() { # bug 11546
1052 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1055 lctl set_param fail_loc=0x80000801
1056 cp $DIR/$tfile /dev/null &
1059 lctl set_param fail_loc=0
1060 drop_bl_callback rm -f $DIR/$tfile
1062 do_facet client "df $DIR"
1064 run_test 58 "Eviction in the middle of open RPC reply processing"
1066 test_59() { # bug 10589
1067 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1068 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1069 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1070 lctl set_param fail_loc=0x311
1071 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1072 [ $? = 0 ] || error "dd write failed"
1073 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1074 lctl set_param fail_loc=0
1076 zconf_umount `hostname` $MOUNT2 -f
1077 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1078 [ $? = 0 ] || error "dd read failed"
1079 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1080 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1082 run_test 59 "Read cancel race on client eviction"
1085 # we assume that all md changes are in the MDT0 changelog
1086 if [ $MDSCOUNT -gt 1 ]; then
1087 error_ignore 17935 $*
1094 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
1095 awk '{gsub(/_UUID/,""); print $1}' | head -1)
1100 # Register (and start) changelog
1101 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1102 echo "Registered as $MDT0 changelog user $USER"
1104 # Generate a large number of changelog entries
1105 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1109 # Unlink files in the background
1110 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1114 # Failover the MDS while unlinks are happening
1115 facet_failover $SINGLEMDS
1117 # Wait for unlinkmany to finish
1120 # Check if all the create/unlink events were recorded
1122 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1123 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1124 echo "$cl_count unlinks in $MDT0 changelog"
1126 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1127 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1128 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1129 if [ $USERS -eq 0 ]; then
1130 [ $cl_count -eq $NUM_FILES ] || \
1131 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1132 # Also make sure we can clear large changelogs
1133 cl_count=$($LFS changelog $FSNAME | wc -l)
1134 [ $cl_count -le 2 ] || \
1135 error "Changelog not empty: $cl_count entries"
1137 # If there are other users, there may be other unlinks in the log
1138 [ $cl_count -ge $NUM_FILES ] || \
1139 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1140 echo "$USERS other changelog users; can't verify clear"
1143 run_test 60 "Add Changelog entries during MDS failover"
1147 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1148 mdtosc=${mdtosc/-MDT*/-MDT\*}
1149 local cflags="osc.$mdtosc.connect_flags"
1150 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1151 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1153 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1154 # Set the default stripe of $DIR/$tdir to put the files to ost1
1155 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1157 replay_barrier $SINGLEMDS
1158 createmany -o $DIR/$tdir/$tfile-%d 10
1159 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1161 fail_abort $SINGLEMDS
1163 touch $DIR/$tdir/$tfile
1164 local id=`$LFS getstripe $DIR/$tdir/$tfile | awk '$1 == 0 { print $2 }'`
1165 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1170 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1172 check_cli_ir_state()
1174 local NODE=${1:-$HOSTNAME}
1176 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1177 awk '/imperative_recovery:/ { print \\\$2}'")
1178 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1179 error "Error state $st, must be ENABLED or DISABLED"
1183 check_target_ir_state()
1186 local name=${target}_svc
1187 local recovery_proc=obdfilter.${!name}.recovery_status
1190 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1191 awk '/IR:/{ print \\\$2}'")
1192 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1193 error "Error state $st, must be ENABLED or DISABLED"
1199 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1204 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1205 awk '/state:/{ print \\\$2 }'")
1209 nidtbl_version_mgs()
1211 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1212 awk '/nidtbl_version:/{ print \\\$2 }'")
1216 # nidtbl_version_client <mds1|client> [node]
1217 nidtbl_version_client()
1220 local node=${2:-$HOSTNAME}
1222 if [ X$cli = Xclient ]; then
1225 local obdtype=${cli/%[0-9]*/}
1226 [ $obdtype != mds ] && error "wrong parameters $cli"
1228 node=$(facet_active_host $cli)
1233 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1234 awk "/$cli/{print \$6}" |sort -u)
1236 # in case there are multiple mounts on the client node
1238 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1242 nidtbl_versions_match()
1244 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1247 target_instance_match()
1253 obdtype=${srv/%[0-9]*/}
1264 error "invalid target type" $srv
1269 local target=${srv}_svc
1270 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1271 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
1272 awk '/instance/{ print $2 }' |head -1)
1274 return $([ $si -eq $ci ])
1279 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1280 { skip "MGS without IR support"; return 0; }
1282 # MDT was just restarted in the previous test, make sure everything
1285 while [ $cnt -gt 0 ]; do
1286 nidtbl_versions_match && break
1292 set_ir_status disabled
1294 local prev_ver=$(nidtbl_version_client client)
1296 local saved_FAILURE_MODE=$FAILURE_MODE
1297 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1301 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1302 error "version must not change due to IR disabled"
1303 target_instance_match ost1 || error "instance mismatch"
1307 FAILURE_MODE=$saved_FAILURE_MODE
1309 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1313 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1314 { skip "MGS without IR support"; return 0; }
1318 local OST1_IMP=$(get_osc_import_name client ost1)
1320 # disable pinger recovery
1321 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1325 target_instance_match ost1 || error "instance mismatch"
1326 nidtbl_versions_match || error "version must match"
1328 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1330 run_test 101 "IR: Make sure IR works w/o normal recovery"
1334 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1335 { skip "MGS without IR support"; return 0; }
1337 local clients=${CLIENTS:-$HOSTNAME}
1344 # let's have a new nidtbl version
1347 # sleep for a while so that clients can see the failure of ost
1348 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1349 # int mgc_request.c:
1350 # define MGC_TIMEOUT_MIN_SECONDS 5
1351 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1352 local count=30 # 20 seconds at most
1353 while [ $count -gt 0 ]; do
1354 nidtbl_versions_match && break
1359 nidtbl_versions_match || error "nidtbl mismatch"
1362 old_version=$(nidtbl_version_client client)
1364 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1367 combined_mgs_mds && mgsdev=mds1
1368 remount_facet $mgsdev
1371 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1374 new_version=$(nidtbl_version_client client)
1375 [ $new_version -lt $old_version ] &&
1376 error "nidtbl version wrong after mgs restarts"
1379 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1383 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1384 { skip "MGS without IR support"; return 0; }
1386 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1388 # workaround solution to generate config log on the mds
1394 # We need this test because mds is like a client in IR context.
1395 start mds1 $MDSDEV1 || error "MDS should start w/o mgs"
1397 # start mgs and remount mds w/ ir
1401 # remount client so that fsdb will be created on the MGS
1402 umount_client $MOUNT || error "umount failed"
1403 mount_client $MOUNT || error "mount failed"
1405 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1407 while [ $count -gt 0 ]; do
1408 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1413 # after a while, mds should be able to reconnect to mgs and fetch
1414 # up-to-date nidtbl version
1415 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1420 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1424 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1425 { skip "MGS without IR support"; return 0; }
1430 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1431 error "OST1 cannot start"
1434 local ir_state=$(check_target_ir_state ost1)
1435 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1436 error "ir status on ost1 should be DISABLED"
1438 run_test 104 "IR: ost can disable IR voluntarily"
1442 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1443 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1444 { skip "MGS without IR support"; return 0; }
1448 # get one of the clients from client list
1449 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1451 local old_MOUNTOPT=$MOUNTOPT
1452 MOUNTOPT=${MOUNTOPT},noir
1453 zconf_umount $rcli $MOUNT || error "umount failed"
1454 zconf_mount $rcli $MOUNT || error "mount failed"
1456 # make sure lustre mount at $rcli disabling IR
1457 local ir_state=$(check_cli_ir_state $rcli)
1458 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1459 error "IR state must be DISABLED at $rcli"
1461 # Since the client just mounted, its last_rcvd entry is not on disk.
1462 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1463 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1464 $SETSTRIPE -i 0 $DIR/$tfile
1465 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1467 # make sure MGS's state is Partial
1468 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1471 # make sure IR on ost1 is DISABLED
1472 local ir_state=$(check_target_ir_state ost1)
1473 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1474 error "IR status on ost1 should be DISABLED"
1477 MOUNTOPT=$old_MOUNTOPT
1478 zconf_umount $rcli $MOUNT || error "umount failed"
1479 zconf_mount $rcli $MOUNT || error "mount failed"
1481 # make sure MGS's state is full
1482 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1485 # make sure IR on ost1 is ENABLED
1486 local ir_state=$(check_target_ir_state ost1)
1487 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1488 error "IR status on ost1 should be ENABLED"
1492 run_test 105 "IR: NON IR clients support"
1494 complete $(basename $0) $SECONDS
1495 check_and_cleanup_lustre