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