Whamcloud - gitweb
* newconfig liblustre/tcpnal runs sanity OK
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -e
4
5 #         bug  2986 5494
6 ALWAYS_EXCEPT="20b  24"
7
8
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10
11 . $LUSTRE/tests/test-framework.sh
12
13 init_test_env $@
14
15 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
16
17 build_test_filter
18
19
20 # Allow us to override the setup if we already have a mounted system by
21 # setting SETUP=" " and CLEANUP=" "
22 SETUP=${SETUP:-"setup"}
23 CLEANUP=${CLEANUP:-"cleanup"}
24 FORCE=${FORCE:-"--force"}
25
26 make_config() {
27     rm -f $XMLCONFIG
28     add_mds mds --dev $MDSDEV --size $MDSSIZE
29     add_lov lov1 mds --stripe_sz $STRIPE_BYTES \
30         --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
31     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
32     add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
33     add_client client mds --lov lov1 --path $MOUNT
34 }
35
36 setup() {
37     make_config
38     start ost --reformat $OSTLCONFARGS 
39     start ost2 --reformat $OSTLCONFARGS 
40     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
41     start mds $MDSLCONFARGS --reformat
42     grep " $MOUNT " /proc/mounts || zconf_mount `hostname`  $MOUNT
43 }
44
45 cleanup() {
46     zconf_umount `hostname` $MOUNT
47     stop mds ${FORCE} $MDSLCONFARGS
48     stop ost2 ${FORCE}
49     stop ost ${FORCE} --dump $TMP/recovery-small-`hostname`.log
50 }
51
52 replay() {
53     do_mds "sync"
54     do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
55     do_client "$1" &
56     shutdown_mds -f
57     start_mds
58     wait
59     do_client "df -h $MOUNT" # trigger failover, if we haven't already
60 }
61
62 if [ ! -z "$EVAL" ]; then
63     eval "$EVAL"
64     exit $?
65 fi
66
67 if [ "$ONLY" == "cleanup" ]; then
68     sysctl -w portals.debug=0 || true
69     FORCE=--force cleanup
70     exit
71 fi
72
73 REFORMAT=--reformat $SETUP
74 unset REFORMAT
75
76 [ "$ONLY" == "setup" ] && exit
77
78 test_1() {
79     drop_request "mcreate $MOUNT/1"  || return 1
80     drop_reint_reply "mcreate $MOUNT/2"    || return 2
81 }
82 run_test 1 "mcreate: drop req, drop rep"
83
84 test_2() {
85     drop_request "tchmod 111 $MOUNT/2"  || return 1
86     drop_reint_reply "tchmod 666 $MOUNT/2"    || return 2
87 }
88 run_test 2 "chmod: drop req, drop rep"
89
90 test_3() {
91     drop_request "statone $MOUNT/2" || return 1
92     drop_reply "statone $MOUNT/2"   || return 2
93 }
94 run_test 3 "stat: drop req, drop rep"
95
96 test_4() {
97     do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
98     drop_request "cat $MOUNT/resolv.conf > /dev/null"   || return 2
99     drop_reply "cat $MOUNT/resolv.conf > /dev/null"     || return 3
100 }
101 run_test 4 "open: drop req, drop rep"
102
103 test_5() {
104     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
105     drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
106     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
107 }
108 run_test 5 "rename: drop req, drop rep"
109
110 test_6() {
111     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
112     drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
113 }
114 run_test 6 "link: drop req, drop rep"
115
116 test_7() {
117     drop_request "munlink $MOUNT/link1"   || return 1
118     drop_reint_reply "munlink $MOUNT/link2"     || return 2
119 }
120 run_test 7 "unlink: drop req, drop rep"
121
122 #bug 1423
123 test_8() {
124     drop_reint_reply "touch $MOUNT/renamed"    || return 1
125 }
126 run_test 8 "touch: drop rep (bug 1423)"
127
128 #bug 1420
129 test_9() {
130     pause_bulk "cp /etc/profile $MOUNT"       || return 1
131     do_facet client "cp /etc/termcap $MOUNT"  || return 2
132     do_facet client "sync"
133     do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
134 }
135 run_test 9 "pause bulk on OST (bug 1420)"
136
137 #bug 1521
138 test_10() {
139     do_facet client mcreate $MOUNT/$tfile        || return 1
140     drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || return 2
141     # wait for the mds to evict the client
142     #echo "sleep $(($TIMEOUT*2))"
143     #sleep $(($TIMEOUT*2))
144     do_facet client touch $MOUNT/$tfile || echo "touch failed, evicted"
145     do_facet client checkstat -v -p 0777 $MOUNT/$tfile  || return 3
146     do_facet client "munlink $MOUNT/$tfile"
147 }
148 run_test 10 "finish request on server after client eviction (bug 1521)"
149
150 #bug 2460
151 # wake up a thread waiting for completion after eviction
152 test_11(){
153     do_facet client multiop $MOUNT/$tfile Ow  || return 1
154     do_facet client multiop $MOUNT/$tfile or  || return 2
155
156     cancel_lru_locks OSC
157
158     do_facet client multiop $MOUNT/$tfile or  || return 3
159     drop_bl_callback multiop $MOUNT/$tfile Ow  || 
160         echo "client evicted, as expected"
161
162     do_facet client munlink $MOUNT/$tfile  || return 4
163 }
164 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
165
166 #b=2494
167 test_12(){
168     $LCTL mark multiop $MOUNT/$tfile OS_c 
169     do_facet mds "sysctl -w lustre.fail_loc=0x115"
170     clear_failloc mds $((TIMEOUT * 2)) &
171     multiop $MOUNT/$tfile OS_c  &
172     PID=$!
173 #define OBD_FAIL_MDS_CLOSE_NET           0x115
174     sleep 2
175     kill -USR1 $PID
176     echo "waiting for multiop $PID"
177     wait $PID || return 2
178     do_facet client munlink $MOUNT/$tfile  || return 3
179 }
180 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
181
182 # Bug 113, check that readdir lost recv timeout works.
183 test_13() {
184     mkdir /mnt/lustre/readdir || return 1
185     touch /mnt/lustre/readdir/newentry || return
186 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
187     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
188     ls /mnt/lustre/readdir || return 3
189     do_facet mds "sysctl -w lustre.fail_loc=0"
190     rm -rf /mnt/lustre/readdir || return 4
191 }
192 run_test 13 "mdc_readpage restart test (bug 1138)"
193
194 # Bug 113, check that readdir lost send timeout works.
195 test_14() {
196     mkdir /mnt/lustre/readdir
197     touch /mnt/lustre/readdir/newentry
198 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
199     do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
200     ls /mnt/lustre/readdir || return 1
201     do_facet mds "sysctl -w lustre.fail_loc=0"
202 }
203 run_test 14 "mdc_readpage resend test (bug 1138)"
204
205 test_15() {
206     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
207     touch $DIR/$tfile && return 1
208     return 0
209 }
210 run_test 15 "failed open (-ENOMEM)"
211
212 READ_AHEAD=`cat /proc/fs/lustre/llite/*/max_read_ahead_mb | head -n 1`
213 stop_read_ahead() {
214    for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do 
215       echo 0 > $f
216    done
217 }
218
219 start_read_ahead() {
220    for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do 
221       echo $READ_AHEAD > $f
222    done
223 }
224
225 test_16() {
226     do_facet client cp /etc/termcap $MOUNT
227     sync
228     stop_read_ahead
229
230 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
231     sysctl -w lustre.fail_loc=0x80000504
232     cancel_lru_locks OSC
233     # will get evicted here
234     do_facet client "cmp /etc/termcap $MOUNT/termcap"  && return 1
235     sysctl -w lustre.fail_loc=0
236     # give recovery a chance to finish (shouldn't take long)
237     sleep $TIMEOUT
238     do_facet client "cmp /etc/termcap $MOUNT/termcap"  || return 2
239     start_read_ahead
240 }
241 run_test 16 "timeout bulk put, evict client (2732)"
242
243 test_17() {
244     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
245     # client will get evicted here
246     sysctl -w lustre.fail_loc=0x80000503
247     # need to ensure we send an RPC
248     do_facet client cp /etc/termcap $DIR/$tfile
249     sync
250
251     sleep $TIMEOUT
252     sysctl -w lustre.fail_loc=0
253     do_facet client "df $DIR"
254     # expect cmp to fail
255     do_facet client "cmp /etc/termcap $DIR/$tfile"  && return 1
256     do_facet client "rm $DIR/$tfile" || return 2
257     return 0
258 }
259 run_test 17 "timeout bulk get, evict client (2732)"
260
261 test_18a() {
262     do_facet client mkdir -p $MOUNT/$tdir
263     f=$MOUNT/$tdir/$tfile
264
265     cancel_lru_locks OSC
266     pgcache_empty || return 1
267
268     # 1 stripe on ost2
269     lfs setstripe $f $((128 * 1024)) 1 1
270
271     do_facet client cp /etc/termcap $f
272     sync
273     local osc2_dev=`$LCTL device_list | \
274         awk '(/ost2.*client_facet/){print $4}' `
275     $LCTL --device %$osc2_dev deactivate
276     # my understanding is that there should be nothing in the page
277     # cache after the client reconnects?     
278     rc=0
279     pgcache_empty || rc=2
280     $LCTL --device %$osc2_dev activate
281     rm -f $f
282     return $rc
283 }
284 run_test 18a "manual ost invalidate clears page cache immediately"
285
286 test_18b() {
287     do_facet client mkdir -p $MOUNT/$tdir
288     f=$MOUNT/$tdir/$tfile
289     f2=$MOUNT/$tdir/${tfile}-2
290
291     cancel_lru_locks OSC
292     pgcache_empty || return 1
293
294     # shouldn't have to set stripe size of count==1
295     lfs setstripe $f $((128 * 1024)) 0 1
296     lfs setstripe $f2 $((128 * 1024)) 0 1
297
298     do_facet client cp /etc/termcap $f
299     sync
300     # just use this write to trigger the client's eviction from the ost
301 # OBD_FAIL_PTLRPC_BULK_GET_NET|OBD_FAIL_ONCE
302     sysctl -w lustre.fail_loc=0x80000503
303     do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
304     sync
305     sysctl -w lustre.fail_loc=0
306     # allow recovery to complete
307     sleep $((TIMEOUT + 2))
308     # my understanding is that there should be nothing in the page
309     # cache after the client reconnects?     
310     rc=0
311     pgcache_empty || rc=2
312     rm -f $f $f2
313     return $rc
314 }
315 run_test 18b "eviction and reconnect clears page cache (2766)"
316
317 test_19a() {
318     f=$MOUNT/$tfile
319     do_facet client mcreate $f        || return 1
320     drop_ldlm_cancel "chmod 0777 $f"  || echo evicted
321
322     do_facet client checkstat -v -p 0777 $f  || echo evicted
323     # let the client reconnect
324     sleep 5
325     do_facet client "munlink $f"
326 }
327 run_test 19a "test expired_lock_main on mds (2867)"
328
329 test_19b() {
330     f=$MOUNT/$tfile
331     do_facet client multiop $f Ow  || return 1
332     do_facet client multiop $f or  || return 2
333
334     cancel_lru_locks OSC
335
336     do_facet client multiop $f or  || return 3
337     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
338
339     do_facet client munlink $f  || return 4
340 }
341 run_test 19b "test expired_lock_main on ost (2867)"
342
343 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
344         mkdir -p $DIR/$tdir
345         multiop $DIR/$tdir/${tfile} O_wc &
346         MULTI_PID=$!
347         sleep 1
348         cancel_lru_locks OSC
349 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
350         do_facet ost sysctl -w lustre.fail_loc=0x80000308
351         kill -USR1 $MULTI_PID
352         wait $MULTI_PID
353         rc=$?
354         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
355 }
356 run_test 20a "ldlm_handle_enqueue error (should return error)" 
357
358 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
359         mkdir -p $DIR/$tdir
360         touch $DIR/$tdir/${tfile}
361         cancel_lru_locks OSC
362 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
363         do_facet ost sysctl -w lustre.fail_loc=0x80000308
364         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
365                 error "didn't fail open enqueue" || true
366 }
367 run_test 20b "ldlm_handle_enqueue error (should return error)"
368
369 #b_cray run_test 21a "drop close request while close and open are both in flight"
370 #b_cray run_test 21b "drop open request while close and open are both in flight"
371 #b_cray run_test 21c "drop both request while close and open are both in flight"
372 #b_cray run_test 21d "drop close reply while close and open are both in flight"
373 #b_cray run_test 21e "drop open reply while close and open are both in flight"
374 #b_cray run_test 21f "drop both reply while close and open are both in flight"
375 #b_cray run_test 21g "drop open reply and close request while close and open are both in flight"
376 #b_cray run_test 21h "drop open request and close reply while close and open are both in flight"
377 #b_cray run_test 22 "drop close request and do mknod"
378 #b_cray run_test 23 "client hang when close a file after mds crash"
379
380 test_24() {     # bug 2248 - eviction fails writeback but app doesn't see it
381         mkdir -p $DIR/$tdir
382         cancel_lru_locks OSC
383         multiop $DIR/$tdir/$tfile Owy_wyc &
384         MULTI_PID=$!
385         usleep 500
386 # OBD_FAIL_PTLRPC_BULK_GET_NET|OBD_FAIL_ONCE
387         sysctl -w lustre.fail_loc=0x80000503
388         usleep 500
389         kill -USR1 $MULTI_PID
390         wait $MULTI_PID
391         rc=$?
392         sysctl -w lustre.fail_loc=0x0
393         client_reconnect
394         [ $rc -eq 0 ] && error "multiop didn't fail fsync: rc $rc" || true
395 }
396 run_test 24 "fsync error (should return error)"
397
398 test_26() {      # bug 5921 - evict dead exports 
399 # this test can only run from a client on a separate node.
400         [ "`lsmod | grep obdfilter`" ] && \
401             echo "skipping test 26 (local OST)" && return
402         [ "`lsmod | grep mds`" ] && \
403             echo "skipping test 26 (local MDS)" && return
404         OST_FILE=/proc/fs/lustre/obdfilter/ost_svc/num_exports
405         OST_EXP="`do_facet ost cat $OST_FILE`"
406         OST_NEXP1=`echo $OST_EXP | cut -d' ' -f2`
407         echo starting with $OST_NEXP1 OST exports
408 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
409         do_facet client sysctl -w lustre.fail_loc=0x505
410         # evictor takes up to 2.25x to evict.  But if there's a 
411         # race to start the evictor from various obds, the loser
412         # might have to wait for the next ping.
413         echo Waiting for $(($TIMEOUT * 4)) secs
414         sleep $(($TIMEOUT * 4))
415         OST_EXP="`do_facet ost cat $OST_FILE`"
416         OST_NEXP2=`echo $OST_EXP | cut -d' ' -f2`
417         echo ending with $OST_NEXP2 OST exports
418         do_facet client sysctl -w lustre.fail_loc=0x0
419         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted"
420         return 0
421 }
422 run_test 26 "evict dead exports"
423
424 test_27() {
425         [ "`lsmod | grep mds`" ] || \
426             { echo "skipping test 27 (non-local MDS)" && return 0; }
427         mkdir -p $DIR/$tdir
428         writemany -q -a $DIR/$tdir/$tfile 0 5 &
429         CLIENT_PID=$!
430         sleep 1
431         FAILURE_MODE="SOFT"
432         facet_failover mds
433 #define OBD_FAIL_OSC_SHUTDOWN            0x407
434         sysctl -w lustre.fail_loc=0x80000407
435         # need to wait for reconnect
436         echo -n waiting for fail_loc
437         while [ `sysctl -n lustre.fail_loc` -eq -2147482617 ]; do
438             sleep 1
439             echo -n .
440         done
441         facet_failover mds
442         #no crashes allowed!
443         kill -USR1 $CLIENT_PID
444         wait $CLIENT_PID 
445         true
446 }
447 run_test 27 "fail LOV while using OSC's"
448
449 test_28() {      # bug 6086 - error adding new clients
450         do_facet client mcreate $MOUNT/$tfile        || return 1
451         drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || return 2
452         #define OBD_FAIL_MDS_ADD_CLIENT 0x12f
453         do_facet mds sysctl -w lustre.fail_loc=0x8000012f
454         # fail once (evicted), reconnect fail (fail_loc), ok
455         df || (sleep 1; df) || (sleep 1; df) || error "reconnect failed"
456         rm -f $MOUNT/$tfile
457         fail mds                # verify MDS last_rcvd can be loaded
458 }
459 run_test 28 "handle error adding new clients (bug 6086)"
460
461 test_50() {
462         mkdir -p $DIR/$tdir
463         # put a load of file creates/writes/deletes
464         writemany -q $DIR/$tdir/$tfile 0 5 &
465         CLIENT_PID=$!
466         echo writemany pid $CLIENT_PID
467         sleep 10
468         FAILURE_MODE="SOFT"
469         fail mds
470         # wait for client to reconnect to MDS
471         sleep 60
472         fail mds
473         sleep 60
474         fail mds
475         # client process should see no problems even though MDS went down
476         sleep $TIMEOUT
477         kill -USR1 $CLIENT_PID
478         wait $CLIENT_PID 
479         rc=$?
480         echo writemany returned $rc
481         #these may fail because of eviction due to slow AST response.
482         return $rc
483 }
484 run_test 50 "failover MDS under load"
485
486 test_51() {
487         mkdir -p $DIR/$tdir
488         # put a load of file creates/writes/deletes
489         writemany -q $DIR/$tdir/$tfile 0 5 &
490         CLIENT_PID=$!
491         sleep 1
492         FAILURE_MODE="SOFT"
493         facet_failover mds
494         # failover at various points during recovery
495         SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
496         echo will failover at $SEQ
497         for i in $SEQ
498           do
499           echo failover in $i sec
500           sleep $i
501           facet_failover mds
502         done
503         # client process should see no problems even though MDS went down
504         # and recovery was interrupted
505         sleep $TIMEOUT
506         kill -USR1 $CLIENT_PID
507         wait $CLIENT_PID 
508         rc=$?
509         echo writemany returned $rc
510         return $rc
511 }
512 run_test 51 "failover MDS during recovery"
513
514 test_52_guts() {
515         do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
516         CLIENT_PID=$!
517         echo writemany pid $CLIENT_PID
518         sleep 10
519         FAILURE_MODE="SOFT"
520         fail ost
521         rc=0
522         wait $CLIENT_PID || rc=$?
523         # active client process should see an EIO for down OST
524         [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
525         # but timing or failover setup may allow success
526         [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
527         echo "writemany returned $rc"
528         return $rc
529 }
530
531 test_52() {
532         mkdir -p $DIR/$tdir
533         test_52_guts
534         rc=$?
535         [ $rc -ne 0 ] && { return $rc; }
536         # wait for client to reconnect to OST
537         sleep 30
538         test_52_guts
539         rc=$?
540         [ $rc -ne 0 ] && { return $rc; }
541         sleep 30
542         test_52_guts
543         rc=$?
544         client_reconnect
545         #return $rc
546 }
547 run_test 52 "failover OST under load"
548
549
550 FORCE=--force $CLEANUP