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