Whamcloud - gitweb
corrected an error made in setepall in test-framework.sh, which affects
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1
2 #!/bin/bash
3
4 set -e
5
6 #         bug  11190 5494 7288 5493
7 ALWAYS_EXCEPT="19b   24   27   52 $RECOVERY_SMALL_EXCEPT"
8
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
12 init_test_env $@
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
14
15 build_test_filter
16
17 # Allow us to override the setup if we already have a mounted system by
18 # setting SETUP=" " and CLEANUP=" "
19 SETUP=${SETUP:-"setup"}
20 CLEANUP=${CLEANUP:-"cleanup"}
21
22 setup() {
23     formatall
24     setupall
25 }
26
27 cleanup() {
28         cleanupall || { echo "FAILed to clean up"; exit 20; }
29 }
30
31 if [ ! -z "$EVAL" ]; then
32     eval "$EVAL"
33     exit $?
34 fi
35
36 if [ "$ONLY" == "cleanup" ]; then
37     sysctl -w lnet.debug=0 || true
38     cleanup
39     exit
40 fi
41
42 $SETUP
43
44 [ "$ONLY" == "setup" ] && exit
45
46 test_1() {
47     drop_request "mcreate $MOUNT/1"  || return 1
48     drop_reint_reply "mcreate $MOUNT/2"    || return 2
49 }
50 run_test 1 "mcreate: drop req, drop rep"
51
52 test_2() {
53     drop_request "tchmod 111 $MOUNT/2"  || return 1
54     drop_reint_reply "tchmod 666 $MOUNT/2"    || return 2
55 }
56 run_test 2 "chmod: drop req, drop rep"
57
58 test_3() {
59     drop_request "statone $MOUNT/2" || return 1
60     drop_reply "statone $MOUNT/2"   || return 2
61 }
62 run_test 3 "stat: drop req, drop rep"
63
64 test_4() {
65     do_facet client "cp /etc/inittab $MOUNT/inittab" || return 1
66     drop_request "cat $MOUNT/inittab > /dev/null"   || return 2
67     drop_reply "cat $MOUNT/inittab > /dev/null"     || return 3
68 }
69 run_test 4 "open: drop req, drop rep"
70
71 test_5() {
72     drop_request "mv $MOUNT/inittab $MOUNT/renamed" || return 1
73     drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
74     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
75 }
76 run_test 5 "rename: drop req, drop rep"
77
78 [ ! -e $MOUNT/renamed-again ] && cp /etc/inittab $MOUNT/renamed-again
79 test_6() {
80     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
81     drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
82 }
83 run_test 6 "link: drop req, drop rep"
84
85 [ ! -e $MOUNT/link1 ] && mlink $MOUNT/renamed-again $MOUNT/link1
86 [ ! -e $MOUNT/link2 ] && mlink $MOUNT/renamed-again $MOUNT/link2
87 test_7() {
88     drop_request "munlink $MOUNT/link1"   || return 1
89     drop_reint_reply "munlink $MOUNT/link2"     || return 2
90 }
91 run_test 7 "unlink: drop req, drop rep"
92
93 #bug 1423
94 test_8() {
95     drop_reint_reply "touch $MOUNT/$tfile"    || return 1
96 }
97 run_test 8 "touch: drop rep (bug 1423)"
98
99 #bug 1420
100 test_9() {
101     pause_bulk "cp /etc/profile $MOUNT/$tfile"       || return 1
102     do_facet client "cp /etc/termcap $MOUNT/${tfile}.2"  || return 2
103     do_facet client "sync"
104     do_facet client "rm $MOUNT/$tfile $MOUNT/${tfile}.2" || return 3
105 }
106 run_test 9 "pause bulk on OST (bug 1420)"
107
108 #bug 1521
109 test_10() {
110     do_facet client mcreate $MOUNT/$tfile        || return 1
111     drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || echo "evicted as expected"
112     # wait for the mds to evict the client
113     #echo "sleep $(($TIMEOUT*2))"
114     #sleep $(($TIMEOUT*2))
115     do_facet client touch $MOUNT/$tfile || echo "touch failed, evicted"
116     do_facet client checkstat -v -p 0777 $MOUNT/$tfile  || return 3
117     do_facet client "munlink $MOUNT/$tfile"
118 }
119 run_test 10 "finish request on server after client eviction (bug 1521)"
120
121 #bug 2460
122 # wake up a thread waiting for completion after eviction
123 test_11(){
124     do_facet client multiop $MOUNT/$tfile Ow  || return 1
125     do_facet client multiop $MOUNT/$tfile or  || return 2
126
127     cancel_lru_locks osc
128
129     do_facet client multiop $MOUNT/$tfile or  || return 3
130     drop_bl_callback multiop $MOUNT/$tfile Ow || echo "evicted as expected"
131
132     do_facet client munlink $MOUNT/$tfile  || return 4
133 }
134 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
135
136 #b=2494
137 test_12(){
138     $LCTL mark multiop $MOUNT/$tfile OS_c 
139     do_facet mds "sysctl -w lustre.fail_loc=0x115"
140     clear_failloc mds $((TIMEOUT * 2)) &
141     multiop $MOUNT/$tfile OS_c  &
142     PID=$!
143 #define OBD_FAIL_MDS_CLOSE_NET           0x115
144     sleep 2
145     kill -USR1 $PID
146     echo "waiting for multiop $PID"
147     wait $PID || return 2
148     do_facet client munlink $MOUNT/$tfile  || return 3
149 }
150 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
151
152 # Bug 113, check that readdir lost recv timeout works.
153 test_13() {
154     mkdir $MOUNT/readdir || return 1
155     touch $MOUNT/readdir/newentry || return
156 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
157     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
158     ls $MOUNT/readdir || return 3
159     do_facet mds "sysctl -w lustre.fail_loc=0"
160     rm -rf $MOUNT/readdir || return 4
161 }
162 run_test 13 "mdc_readpage restart test (bug 1138)"
163
164 # Bug 113, check that readdir lost send timeout works.
165 test_14() {
166     mkdir $MOUNT/readdir
167     touch $MOUNT/readdir/newentry
168 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
169     do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
170     ls $MOUNT/readdir || return 1
171     do_facet mds "sysctl -w lustre.fail_loc=0"
172 }
173 run_test 14 "mdc_readpage resend test (bug 1138)"
174
175 test_15() {
176     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
177     touch $DIR/$tfile && return 1
178     return 0
179 }
180 run_test 15 "failed open (-ENOMEM)"
181
182 READ_AHEAD=`cat $LPROC/llite/*/max_read_ahead_mb | head -n 1`
183 stop_read_ahead() {
184    for f in $LPROC/llite/*/max_read_ahead_mb; do 
185       echo 0 > $f
186    done
187 }
188
189 start_read_ahead() {
190    for f in $LPROC/llite/*/max_read_ahead_mb; do 
191       echo $READ_AHEAD > $f
192    done
193 }
194
195 test_16() {
196     do_facet client cp /etc/termcap $MOUNT
197     sync
198     stop_read_ahead
199
200 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
201     do_facet ost1 sysctl -w lustre.fail_loc=0x80000504
202     cancel_lru_locks osc
203     # OST bulk will time out here, client resends
204     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 1
205     sysctl -w lustre.fail_loc=0
206     # give recovery a chance to finish (shouldn't take long)
207     sleep $TIMEOUT
208     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
209     start_read_ahead
210 }
211 run_test 16 "timeout bulk put, don't evict client (2732)"
212
213 test_17() {
214     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
215     # OST bulk will time out here, client retries
216     sysctl -w lustre.fail_loc=0x80000503
217     # need to ensure we send an RPC
218     do_facet client cp /etc/termcap $DIR/$tfile
219     sync
220
221     sleep $TIMEOUT
222     sysctl -w lustre.fail_loc=0
223     do_facet client "df $DIR"
224     # expect cmp to succeed, client resent bulk
225     do_facet client "cmp /etc/termcap $DIR/$tfile" || return 3
226     do_facet client "rm $DIR/$tfile" || return 4
227     return 0
228 }
229 run_test 17 "timeout bulk get, don't evict client (2732)"
230
231 test_18a() {
232     [ -z ${ost2_svc} ] && echo Skipping, needs 2 osts && return 0
233
234     do_facet client mkdir -p $MOUNT/$tdir
235     f=$MOUNT/$tdir/$tfile
236
237     cancel_lru_locks osc
238     pgcache_empty || return 1
239
240     # 1 stripe on ost2
241     lfs setstripe $f $((128 * 1024)) 1 1
242
243     do_facet client cp /etc/termcap $f
244     sync
245     local osc2dev=`grep ${ost2_svc}-osc- $LPROC/devices | awk '{print $1}'`
246     $LCTL --device $osc2dev deactivate || return 3
247     # my understanding is that there should be nothing in the page
248     # cache after the client reconnects?     
249     rc=0
250     pgcache_empty || rc=2
251     $LCTL --device $osc2dev activate
252     rm -f $f
253     return $rc
254 }
255 run_test 18a "manual ost invalidate clears page cache immediately"
256
257 test_18b() {
258     do_facet client mkdir -p $MOUNT/$tdir
259     f=$MOUNT/$tdir/$tfile
260     f2=$MOUNT/$tdir/${tfile}-2
261
262     cancel_lru_locks osc
263     pgcache_empty || return 1
264
265     # shouldn't have to set stripe size of count==1
266     lfs setstripe $f $((128 * 1024)) 0 1
267     lfs setstripe $f2 $((128 * 1024)) 0 1
268
269     do_facet client cp /etc/termcap $f
270     sync
271     ost_evict_client
272     # allow recovery to complete
273     sleep $((TIMEOUT + 2))
274     # my understanding is that there should be nothing in the page
275     # cache after the client reconnects?     
276     rc=0
277     pgcache_empty || rc=2
278     rm -f $f $f2
279     return $rc
280 }
281 run_test 18b "eviction and reconnect clears page cache (2766)"
282
283 test_19a() {
284     f=$MOUNT/$tfile
285     do_facet client mcreate $f        || return 1
286     drop_ldlm_cancel "chmod 0777 $f"  || echo "evicted as expected"
287
288     do_facet client checkstat -v -p 0777 $f  || echo evicted
289     # let the client reconnect
290     sleep 5
291     do_facet client "munlink $f"
292 }
293 run_test 19a "test expired_lock_main on mds (2867)"
294
295 test_19b() {
296     f=$MOUNT/$tfile
297     do_facet client multiop $f Ow  || return 1
298     do_facet client multiop $f or  || return 2
299
300     cancel_lru_locks osc
301
302     do_facet client multiop $f or  || return 3
303     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
304
305     do_facet client munlink $f  || return 4
306 }
307 run_test 19b "test expired_lock_main on ost (2867)"
308
309 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
310         mkdir -p $DIR/$tdir
311         multiop $DIR/$tdir/${tfile} O_wc &
312         MULTI_PID=$!
313         sleep 1
314         cancel_lru_locks osc
315 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
316         do_facet ost1 sysctl -w lustre.fail_loc=0x80000308
317         kill -USR1 $MULTI_PID
318         wait $MULTI_PID
319         rc=$?
320         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
321 }
322 run_test 20a "ldlm_handle_enqueue error (should return error)" 
323
324 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
325         mkdir -p $DIR/$tdir
326         touch $DIR/$tdir/${tfile}
327         cancel_lru_locks osc
328 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
329         do_facet ost1 sysctl -w lustre.fail_loc=0x80000308
330         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
331                 error "didn't fail open enqueue" || true
332 }
333 run_test 20b "ldlm_handle_enqueue error (should return error)"
334
335 test_21a() {
336        mkdir -p $DIR/$tdir-1
337        mkdir -p $DIR/$tdir-2
338        multiop $DIR/$tdir-1/f O_c &
339        close_pid=$!
340
341        do_facet mds "sysctl -w lustre.fail_loc=0x80000129"
342        multiop $DIR/$tdir-2/f Oc &
343        open_pid=$!
344        sleep 1
345        do_facet mds "sysctl -w lustre.fail_loc=0"
346
347        do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
348        kill -USR1 $close_pid
349        cancel_lru_locks mdc
350        wait $close_pid || return 1
351        wait $open_pid || return 2
352        do_facet mds "sysctl -w lustre.fail_loc=0"
353
354        $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
355        $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
356
357        rm -rf $DIR/$tdir-*
358 }
359 run_test 21a "drop close request while close and open are both in flight"
360
361 test_21b() {
362        mkdir -p $DIR/$tdir-1
363        mkdir -p $DIR/$tdir-2
364        multiop $DIR/$tdir-1/f O_c &
365        close_pid=$!
366
367        do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
368        mcreate $DIR/$tdir-2/f &
369        open_pid=$!
370        sleep 1
371        do_facet mds "sysctl -w lustre.fail_loc=0"
372
373        kill -USR1 $close_pid
374        cancel_lru_locks mdc
375        wait $close_pid || return 1
376        wait $open_pid || return 3
377
378        $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
379        $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
380        rm -rf $DIR/$tdir-*
381 }
382 run_test 21b "drop open request while close and open are both in flight"
383
384 test_21c() {
385        mkdir -p $DIR/$tdir-1
386        mkdir -p $DIR/$tdir-2
387        multiop $DIR/$tdir-1/f O_c &
388        close_pid=$!
389
390        do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
391        mcreate $DIR/$tdir-2/f &
392        open_pid=$!
393        sleep 3
394        do_facet mds "sysctl -w lustre.fail_loc=0"
395
396        do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
397        kill -USR1 $close_pid
398        cancel_lru_locks mdc
399        wait $close_pid || return 1
400        wait $open_pid || return 2
401
402        do_facet mds "sysctl -w lustre.fail_loc=0"
403
404        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
405        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
406        rm -rf $DIR/$tdir-*
407 }
408 run_test 21c "drop both request while close and open are both in flight"
409
410 test_21d() {
411        mkdir -p $DIR/$tdir-1
412        mkdir -p $DIR/$tdir-2
413        multiop $DIR/$tdir-1/f O_c &
414        pid=$!
415
416        do_facet mds "sysctl -w lustre.fail_loc=0x80000129"
417        multiop $DIR/$tdir-2/f Oc &
418        sleep 1
419        do_facet mds "sysctl -w lustre.fail_loc=0"
420
421        do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
422        kill -USR1 $pid
423        cancel_lru_locks mdc
424        wait $pid || return 1
425        do_facet mds "sysctl -w lustre.fail_loc=0"
426
427        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
428        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
429
430        rm -rf $DIR/$tdir-*
431 }
432 run_test 21d "drop close reply while close and open are both in flight"
433
434 test_21e() {
435        mkdir -p $DIR/$tdir-1
436        mkdir -p $DIR/$tdir-2
437        multiop $DIR/$tdir-1/f O_c &
438        pid=$!
439
440        do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
441        touch $DIR/$tdir-2/f &
442        sleep 1
443        do_facet mds "sysctl -w lustre.fail_loc=0"
444
445        kill -USR1 $pid
446        cancel_lru_locks mdc
447        wait $pid || return 1
448
449        sleep $TIMEOUT
450        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
451        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
452        rm -rf $DIR/$tdir-*
453 }
454 run_test 21e "drop open reply while close and open are both in flight"
455
456 test_21f() {
457        mkdir -p $DIR/$tdir-1
458        mkdir -p $DIR/$tdir-2
459        multiop $DIR/$tdir-1/f O_c &
460        pid=$!
461
462        do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
463        touch $DIR/$tdir-2/f &
464        sleep 1
465        do_facet mds "sysctl -w lustre.fail_loc=0"
466
467        do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
468        kill -USR1 $pid
469        cancel_lru_locks mdc
470        wait $pid || return 1
471        do_facet mds "sysctl -w lustre.fail_loc=0"
472
473        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
474        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
475        rm -rf $DIR/$tdir-*
476 }
477 run_test 21f "drop both reply while close and open are both in flight"
478
479 test_21g() {
480        mkdir -p $DIR/$tdir-1
481        mkdir -p $DIR/$tdir-2
482        multiop $DIR/$tdir-1/f O_c &
483        pid=$!
484
485        do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
486        touch $DIR/$tdir-2/f &
487        sleep 1
488        do_facet mds "sysctl -w lustre.fail_loc=0"
489
490        do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
491        kill -USR1 $pid
492        cancel_lru_locks mdc
493        wait $pid || return 1
494        do_facet mds "sysctl -w lustre.fail_loc=0"
495
496        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
497        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
498        rm -rf $DIR/$tdir-*
499 }
500 run_test 21g "drop open reply and close request while close and open are both in flight"
501
502 test_21h() {
503        mkdir -p $DIR/$tdir-1
504        mkdir -p $DIR/$tdir-2
505        multiop $DIR/$tdir-1/f O_c &
506        pid=$!
507
508        do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
509        touch $DIR/$tdir-2/f &
510        touch_pid=$!
511        sleep 1
512        do_facet mds "sysctl -w lustre.fail_loc=0"
513
514        do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
515        cancel_lru_locks mdc
516        kill -USR1 $pid
517        wait $pid || return 1
518        do_facet mds "sysctl -w lustre.fail_loc=0"
519
520        wait $touch_pid || return 2
521
522        $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
523        $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
524        rm -rf $DIR/$tdir-*
525 }
526 run_test 21h "drop open request and close reply while close and open are both in flight"
527
528 # bug 3462 - multiple MDC requests
529 test_22() {
530     f1=$DIR/${tfile}-1
531     f2=$DIR/${tfile}-2
532     
533     do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
534     multiop $f2 Oc &
535     close_pid=$!
536
537     sleep 1
538     multiop $f1 msu || return 1
539
540     cancel_lru_locks mdc
541     do_facet mds "sysctl -w lustre.fail_loc=0"
542
543     wait $close_pid || return 2
544     rm -rf $f2 || return 4
545 }
546 run_test 22 "drop close request and do mknod"
547
548 test_23() { #b=4561
549     multiop $DIR/$tfile O_c &
550     pid=$!
551     # give a chance for open
552     sleep 5
553
554     # try the close
555     drop_request "kill -USR1 $pid"
556
557     fail mds
558     wait $pid || return 1
559     return 0
560 }
561 run_test 23 "client hang when close a file after mds crash"
562
563 test_24() {     # bug 2248 - eviction fails writeback but app doesn't see it
564         mkdir -p $DIR/$tdir
565         cancel_lru_locks osc
566         multiop $DIR/$tdir/$tfile Owy_wyc &
567         MULTI_PID=$!
568         usleep 500
569         ost_evict_client
570         usleep 500
571         kill -USR1 $MULTI_PID
572         wait $MULTI_PID
573         rc=$?
574         sysctl -w lustre.fail_loc=0x0
575         client_reconnect
576         [ $rc -eq 0 ] && error "multiop didn't fail fsync: rc $rc" || true
577 }
578 run_test 24 "fsync error (should return error)"
579
580 test_26() {      # bug 5921 - evict dead exports by pinger
581 # this test can only run from a client on a separate node.
582         [ "`lsmod | grep obdfilter`" ] && \
583             echo "skipping test 26 (local OST)" && return
584         [ "`lsmod | grep mds`" ] && \
585             echo "skipping test 26 (local MDS)" && return
586         OST_FILE=$LPROC/obdfilter/${ost1_svc}/num_exports
587         OST_EXP="`do_facet ost1 cat $OST_FILE`"
588         OST_NEXP1=`echo $OST_EXP | cut -d' ' -f2`
589         echo starting with $OST_NEXP1 OST exports
590 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
591         do_facet client sysctl -w lustre.fail_loc=0x505
592         # evictor takes up to 2.25x to evict.  But if there's a 
593         # race to start the evictor from various obds, the loser
594         # might have to wait for the next ping.
595         echo Waiting for $(($TIMEOUT * 4)) secs
596         sleep $(($TIMEOUT * 4))
597         OST_EXP="`do_facet ost1 cat $OST_FILE`"
598         OST_NEXP2=`echo $OST_EXP | cut -d' ' -f2`
599         echo ending with $OST_NEXP2 OST exports
600         do_facet client sysctl -w lustre.fail_loc=0x0
601         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted"
602         return 0
603 }
604 run_test 26 "evict dead exports"
605
606 test_26b() {      # bug 10140 - evict dead exports by pinger
607         zconf_mount `hostname` $MOUNT2
608         MDS_FILE=$LPROC/mds/${mds_svc}/num_exports
609         MDS_NEXP1="`do_facet mds cat $MDS_FILE | cut -d' ' -f2`"
610         OST_FILE=$LPROC/obdfilter/${ost1_svc}/num_exports
611         OST_NEXP1="`do_facet ost1 cat $OST_FILE | cut -d' ' -f2`"
612         echo starting with $OST_NEXP1 OST and $MDS_NEXP1 MDS exports
613         zconf_umount `hostname` $MOUNT2 -f
614         # evictor takes up to 2.25x to evict.  But if there's a 
615         # race to start the evictor from various obds, the loser
616         # might have to wait for the next ping.
617         echo Waiting for $(($TIMEOUT * 4)) secs
618         sleep $(($TIMEOUT * 4))
619         OST_NEXP2="`do_facet ost1 cat $OST_FILE | cut -d' ' -f2`"
620         MDS_NEXP2="`do_facet mds cat $MDS_FILE | cut -d' ' -f2`"
621         echo ending with $OST_NEXP2 OST and $MDS_NEXP2 MDS exports
622         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted from OST"
623         [ $MDS_NEXP1 -le $MDS_NEXP2 ] && error "client not evicted from MDS"
624         return 0
625 }
626 run_test 26b "evict dead exports"
627
628 test_27() {
629         [ "`lsmod | grep mds`" ] || \
630             { echo "skipping test 27 (non-local MDS)" && return 0; }
631         mkdir -p $DIR/$tdir
632         writemany -q -a $DIR/$tdir/$tfile 0 5 &
633         CLIENT_PID=$!
634         sleep 1
635         FAILURE_MODE="SOFT"
636         facet_failover mds
637 #define OBD_FAIL_OSC_SHUTDOWN            0x407
638         sysctl -w lustre.fail_loc=0x80000407
639         # need to wait for reconnect
640         echo -n waiting for fail_loc
641         while [ `sysctl -n lustre.fail_loc` -eq -2147482617 ]; do
642             sleep 1
643             echo -n .
644         done
645         facet_failover mds
646         #no crashes allowed!
647         kill -USR1 $CLIENT_PID
648         wait $CLIENT_PID 
649         true
650 }
651 run_test 27 "fail LOV while using OSC's"
652
653 test_28() {      # bug 6086 - error adding new clients
654         do_facet client mcreate $MOUNT/$tfile       || return 1
655         drop_bl_callback "chmod 0777 $MOUNT/$tfile" ||echo "evicted as expected"
656         #define OBD_FAIL_MDS_ADD_CLIENT 0x12f
657         do_facet mds sysctl -w lustre.fail_loc=0x8000012f
658         # fail once (evicted), reconnect fail (fail_loc), ok
659         df || (sleep 1; df) || (sleep 1; df) || error "reconnect failed"
660         rm -f $MOUNT/$tfile
661         fail mds                # verify MDS last_rcvd can be loaded
662 }
663 run_test 28 "handle error adding new clients (bug 6086)"
664
665 test_50() {
666         mkdir -p $DIR/$tdir
667         # put a load of file creates/writes/deletes
668         writemany -q $DIR/$tdir/$tfile 0 5 &
669         CLIENT_PID=$!
670         echo writemany pid $CLIENT_PID
671         sleep 10
672         FAILURE_MODE="SOFT"
673         fail mds
674         # wait for client to reconnect to MDS
675         sleep 60
676         fail mds
677         sleep 60
678         fail mds
679         # client process should see no problems even though MDS went down
680         sleep $TIMEOUT
681         kill -USR1 $CLIENT_PID
682         wait $CLIENT_PID 
683         rc=$?
684         echo writemany returned $rc
685         #these may fail because of eviction due to slow AST response.
686         return $rc
687 }
688 run_test 50 "failover MDS under load"
689
690 test_51() {
691         mkdir -p $DIR/$tdir
692         # put a load of file creates/writes/deletes
693         writemany -q $DIR/$tdir/$tfile 0 5 &
694         CLIENT_PID=$!
695         sleep 1
696         FAILURE_MODE="SOFT"
697         facet_failover mds
698         # failover at various points during recovery
699         SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
700         echo will failover at $SEQ
701         for i in $SEQ
702           do
703           echo failover in $i sec
704           sleep $i
705           facet_failover mds
706         done
707         # client process should see no problems even though MDS went down
708         # and recovery was interrupted
709         sleep $TIMEOUT
710         kill -USR1 $CLIENT_PID
711         wait $CLIENT_PID 
712         rc=$?
713         echo writemany returned $rc
714         return $rc
715 }
716 run_test 51 "failover MDS during recovery"
717
718 test_52_guts() {
719         do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
720         CLIENT_PID=$!
721         echo writemany pid $CLIENT_PID
722         sleep 10
723         FAILURE_MODE="SOFT"
724         fail ost1
725         rc=0
726         wait $CLIENT_PID || rc=$?
727         # active client process should see an EIO for down OST
728         [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
729         # but timing or failover setup may allow success
730         [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
731         echo "writemany returned $rc"
732         return $rc
733 }
734
735 test_52() {
736         mkdir -p $DIR/$tdir
737         test_52_guts
738         rc=$?
739         [ $rc -ne 0 ] && { return $rc; }
740         # wait for client to reconnect to OST
741         sleep 30
742         test_52_guts
743         rc=$?
744         [ $rc -ne 0 ] && { return $rc; }
745         sleep 30
746         test_52_guts
747         rc=$?
748         client_reconnect
749         #return $rc
750 }
751 run_test 52 "failover OST under load"
752
753 # test of open reconstruct
754 test_53() {
755         touch $DIR/$tfile
756         drop_ldlm_reply "./openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
757                 return 2
758 }
759 run_test 53 "touch: drop rep"
760
761 test_54() {
762         zconf_mount `hostname` $MOUNT2
763         touch $DIR/$tfile
764         touch $DIR2/$tfile.1
765         sleep 10
766         cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
767         fail mds
768         umount $MOUNT2
769         ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
770         [ x"$ERROR" == x ] || error "back in time occured"
771 }
772 run_test 54 "back in time"
773
774 # bug 11330 - liblustre application death during I/O locks up OST
775 test_55() {
776         [ "`lsmod | grep obdfilter`" ] || \
777             { echo "skipping test 55 (non-local OST)" && return 0; }    
778
779         mkdir -p $DIR/$tdir
780
781         # first dd should be finished quickly
782         dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4  &
783         DDPID=$!
784         count=0
785         echo  "step1: testing ......"
786         while [ true ]; do
787             if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
788             count=$[count+1]
789             if [ $count -gt 64 ]; then
790                 error "dd should be finished!"
791             fi
792             sleep 1
793         done    
794         echo "(dd_pid=$DDPID, time=$count)successful"
795
796         #define OBD_FAIL_OST_DROP_REQ            0x21d
797         do_facet ost sysctl -w lustre.fail_loc=0x0000021d
798         # second dd will be never finished
799         dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4  &        
800         DDPID=$!
801         count=0
802         echo  "step2: testing ......"
803         while [ $count -le 64 ]; do
804             dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"            
805             if [ -z  $dd_name ]; then 
806                 ls -l $DIR/$tdir
807                 echo  "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
808                 error "dd shouldn't be finished!"
809             fi
810             count=$[count+1]
811             sleep 1
812         done    
813         echo "(dd_pid=$DDPID, time=$count)successful"
814
815         #Recover fail_loc and dd will finish soon
816         do_facet ost sysctl -w lustre.fail_loc=0
817         count=0
818         echo  "step3: testing ......"
819         while [ true ]; do
820             if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
821             count=$[count+1]
822             if [ $count -gt 500 ]; then
823                 error "dd should be finished!"
824             fi
825             sleep 1
826         done    
827         echo "(dd_pid=$DDPID, time=$count)successful"
828
829         rm -rf $DIR/$tdir
830 }
831 run_test 55 "ost_brw_read/write drops timed-out read/write request"
832
833 test_56() { # b=11277
834 #define OBD_FAIL_MDS_RESEND      0x136
835         touch $MOUNT/$tfile
836         do_facet mds sysctl -w lustre.fail_loc=0x80000136
837         stat $MOUNT/$tfile
838         do_facet mds sysctl -w lustre.fail_loc=0
839         rm -f $MOUNT/$tfile
840 }
841 run_test 56 "replace lock race"
842
843 test_57_helper() {
844         # no oscs means no client or mdt 
845         while [ -e $LPROC/osc ]; do
846                 for f in `find $LPROC -type f`; do 
847                         cat $f > /dev/null 2>&1
848                 done
849         done
850 }
851
852 test_57() { # bug 10866
853         test_57_helper &
854         pid=$!
855         sleep 1
856 #define OBD_FAIL_LPROC_REMOVE            0xB00
857         sysctl -w lustre.fail_loc=0x80000B00
858         zconf_umount `hostname` $DIR
859         sysctl -w lustre.fail_loc=0x80000B00
860         fail_abort mds
861         kill -9 $pid
862         sysctl -w lustre.fail_loc=0
863         mount_client $DIR
864         do_facet client "df $DIR"
865 }
866 run_test 57 "read procfs entries causes kernel crash"
867
868 $CLEANUP
869 echo "$0: completed"