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