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