Whamcloud - gitweb
- merge 2 weeks of b1_4 fixes onto HEAD
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -e
4
5 #         bug  2986
6 ALWAYS_EXCEPT="20b"
7
8
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
11 . $LUSTRE/tests/test-framework.sh
12
13 init_test_env $@
14
15 . ${CONFIG:=$LUSTRE/tests/cfg/lmv.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
25 make_config() {
26     rm -f $XMLCONFIG
27
28     if [ "$MDSCOUNT" -gt 1 ]; then
29         add_lmv lmv1
30         for num in `seq $MDSCOUNT`; do
31             MDSDEV=$TMP/mds${num}-`hostname`
32             add_mds mds$num --dev $MDSDEV --size $MDSSIZE --master --lmv lmv1
33         done
34         add_lov_to_lmv lov1 lmv1 --stripe_sz $STRIPE_BYTES \
35             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
36         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
37         add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
38         add_client client --lmv lmv1 --lov lov1 --path $MOUNT
39     else
40         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
41         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
42             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
43         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
44         add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
45         add_client client --mds mds1_svc --lov lov1 --path $MOUNT
46     fi
47 }
48
49 setup() {
50     make_config
51     start ost --reformat $OSTLCONFARGS 
52     start ost2 --reformat $OSTLCONFARGS 
53     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
54     start mds $MDSLCONFARGS --reformat
55     grep " $MOUNT " /proc/mounts || zconf_mount `hostname`  $MOUNT
56 }
57
58 cleanup() {
59     zconf_umount `hostname` $MOUNT
60     if [ "$MDSCOUNT" -gt 1 ]; then
61         for num in `seq $MDSCOUNT`; do
62             stop mds$num ${FORCE} $MDSLCONFARGS
63         done
64     else
65         stop mds ${FORCE} $MDSLCONFARGS
66     fi
67     stop ost2 ${FORCE} --dump cleanup.log
68     stop ost ${FORCE} --dump cleanup.log
69 }
70
71 if [ ! -z "$EVAL" ]; then
72     eval "$EVAL"
73     exit $?
74 fi
75
76 if [ "$ONLY" == "setup" ]; then
77     setup
78     exit
79 fi
80
81 if [ "$ONLY" == "cleanup" ]; then
82     sysctl -w portals.debug=0 || true
83     cleanup
84     exit
85 fi
86
87 REFORMAT=--reformat $SETUP
88 unset REFORMAT
89
90 test_1() {
91     drop_request "mcreate $MOUNT/1"  || return 1
92     drop_reint_reply "mcreate $MOUNT/2"    || return 2
93 }
94 run_test 1 "mcreate: drop req, drop rep"
95
96 test_2() {
97     drop_request "tchmod 111 $MOUNT/2"  || return 1
98     drop_reint_reply "tchmod 666 $MOUNT/2"    || return 2
99 }
100 run_test 2 "chmod: drop req, drop rep"
101
102 test_3() {
103     drop_request "statone $MOUNT/2" || return 1
104     drop_reply "statone $MOUNT/2"   || return 2
105 }
106 run_test 3 "stat: drop req, drop rep"
107
108 test_4() {
109     do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
110     drop_request "cat $MOUNT/resolv.conf > /dev/null"   || return 2
111     drop_reply "cat $MOUNT/resolv.conf > /dev/null"     || return 3
112 }
113 run_test 4 "open: drop req, drop rep"
114
115 test_5() {
116     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
117     drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
118     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
119 }
120 run_test 5 "rename: drop req, drop rep"
121
122 test_6() {
123     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
124     drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
125 }
126 run_test 6 "link: drop req, drop rep"
127
128 test_7() {
129     drop_request "munlink $MOUNT/link1"   || return 1
130     drop_reint_reply "munlink $MOUNT/link2"     || return 2
131 }
132 run_test 7 "unlink: drop req, drop rep"
133
134 #bug 1423
135 test_8() {
136     drop_reint_reply "touch $MOUNT/renamed"    || return 1
137 }
138 run_test 8 "touch: drop rep (bug 1423)"
139
140 #bug 1420
141 test_9() {
142     pause_bulk "cp /etc/profile $MOUNT"       || return 1
143     do_facet client "cp /etc/termcap $MOUNT"  || return 2
144     do_facet client "sync"
145     do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
146 }
147 run_test 9 "pause bulk on OST (bug 1420)"
148
149 #bug 1521
150 test_10() {
151     do_facet client mcreate $MOUNT/f10        || return 1
152     drop_bl_callback "chmod 0777 $MOUNT/f10"  || return 2
153     # wait for the mds to evict the client
154     #echo "sleep $(($TIMEOUT*2))"
155     #sleep $(($TIMEOUT*2))
156     do_facet client touch  $MOUNT/f10 || echo "touch failed, evicted"
157     do_facet client checkstat -v -p 0777 $MOUNT/f10  || return 3
158     do_facet client "munlink $MOUNT/f10"
159 }
160 run_test 10 "finish request on server after client eviction (bug 1521)"
161
162 #bug 2460
163 # wake up a thead waiting for completion after eviction
164 test_11(){
165     do_facet client multiop $MOUNT/$tfile Ow  || return 1
166     do_facet client multiop $MOUNT/$tfile or  || return 2
167
168     cancel_lru_locks OSC
169
170     do_facet client multiop $MOUNT/$tfile or  || return 3
171     drop_bl_callback multiop $MOUNT/$tfile Ow  || 
172         echo "client evicted, as expected"
173
174     do_facet client munlink $MOUNT/$tfile  || return 4
175 }
176 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
177
178 #b=2494
179 test_12(){
180     $LCTL mark multiop $MOUNT/$tfile OS_c 
181     do_facet mds "sysctl -w lustre.fail_loc=0x115"
182     clear_failloc mds $((TIMEOUT * 2)) &
183     multiop $MOUNT/$tfile OS_c  &
184     PID=$!
185 #define OBD_FAIL_MDS_CLOSE_NET           0x115
186     sleep 2
187     kill -USR1 $PID
188     echo "waiting for multiop $PID"
189     wait $PID || return 2
190     do_facet client munlink $MOUNT/$tfile  || return 3
191 }
192 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
193
194 # Bug 113, check that readdir lost recv timeout works.
195 test_13() {
196     mkdir /mnt/lustre/readdir
197     touch /mnt/lustre/readdir/newentry
198 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
199     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
200     ls /mnt/lustre/readdir || return 1
201     do_facet mds "sysctl -w lustre.fail_loc=0"
202     rm -rf /mnt/lustre/readdir
203 }
204 run_test 13 "mdc_readpage restart test (bug 1138)"
205
206 # Bug 113, check that readdir lost send timeout works.
207 test_14() {
208     mkdir /mnt/lustre/readdir
209     touch /mnt/lustre/readdir/newentry
210 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
211     do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
212     ls /mnt/lustre/readdir || return 1
213     do_facet mds "sysctl -w lustre.fail_loc=0"
214 }
215 run_test 14 "mdc_readpage resend test (bug 1138)"
216
217 test_15() {
218     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
219     touch $DIR/$tfile && return 1
220     return 0
221 }
222 run_test 15 "failed open (-ENOMEM)"
223
224 stop_read_ahead() {
225    for f in /proc/fs/lustre/llite/*/read_ahead; do 
226       echo 0 > $f
227    done
228 }
229
230 start_read_ahead() {
231    for f in /proc/fs/lustre/llite/*/read_ahead; do 
232       echo 1 > $f
233    done
234 }
235
236 test_16() {
237     do_facet client cp /etc/termcap $MOUNT
238     sync
239     stop_read_ahead
240
241 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
242     sysctl -w lustre.fail_loc=0x80000504
243     cancel_lru_locks OSC
244     # will get evicted here
245     do_facet client "cmp /etc/termcap $MOUNT/termcap"  && return 1
246     sysctl -w lustre.fail_loc=0
247     # give recovery a chance to finish (shouldn't take long)
248     sleep $TIMEOUT
249     do_facet client "cmp /etc/termcap $MOUNT/termcap"  || return 2
250     start_read_ahead
251 }
252 run_test 16 "timeout bulk put, evict client (2732)"
253
254 test_17() {
255     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
256     # client will get evicted here
257     sysctl -w lustre.fail_loc=0x80000503
258     do_facet client cp /etc/termcap $DIR/$tfile
259     sysctl -w lustre.fail_loc=0
260
261     sleep $TIMEOUT
262     # expect cmp to fail
263     do_facet client "cmp /etc/termcap $DIR/$tfile"  && return 1
264     do_facet client "rm $DIR/$tfile" || return 2
265     return 0
266 }
267 run_test 17 "timeout bulk get, evict client (2732)"
268
269 test_18a() {
270     do_facet client mkdir -p $MOUNT/$tdir
271     f=$MOUNT/$tdir/$tfile
272
273     cancel_lru_locks OSC
274     pgcache_empty || return 1
275
276     # 1 stripe on ost2
277     lfs setstripe $f $((128 * 1024)) 1 1
278
279     do_facet client cp /etc/termcap $f
280     sync
281     local osc2_dev=`$LCTL device_list | \
282         awk '(/ost2.*client_facet/){print $4}' `
283     $LCTL --device %$osc2_dev deactivate
284     # my understanding is that there should be nothing in the page
285     # cache after the client reconnects?     
286     rc=0
287     pgcache_empty || rc=2
288     $LCTL --device %$osc2_dev activate
289     rm -f $f
290     return $rc
291 }
292 run_test 18a "manual ost invalidate clears page cache immediately"
293
294 test_18b() {
295 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
296     do_facet client mkdir -p $MOUNT/$tdir
297     f=$MOUNT/$tdir/$tfile
298     f2=$MOUNT/$tdir/${tfile}-2
299
300     cancel_lru_locks OSC
301     pgcache_empty || return 1
302
303     # shouldn't have to set stripe size of count==1
304     lfs setstripe $f $((128 * 1024)) 0 1
305     lfs setstripe $f2 $((128 * 1024)) 0 1
306
307     do_facet client cp /etc/termcap $f
308     sync
309     # just use this write to trigger the client's eviction from the ost
310     sysctl -w lustre.fail_loc=0x80000503
311     do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
312     sync
313     sysctl -w lustre.fail_loc=0
314     # allow recovery to complete
315     sleep $((TIMEOUT + 2))
316     # my understanding is that there should be nothing in the page
317     # cache after the client reconnects?     
318     rc=0
319     pgcache_empty || rc=2
320     rm -f $f $f2
321     return $rc
322 }
323 run_test 18b "eviction and reconnect clears page cache (2766)"
324
325 test_19a() {
326     f=$MOUNT/$tfile
327     do_facet client mcreate $f        || return 1
328     drop_ldlm_cancel "chmod 0777 $f"  || echo evicted
329
330     do_facet client checkstat -v -p 0777 $f  || echo evicted
331     do_facet client "munlink $f"
332 }
333 run_test 19a "test expired_lock_main on mds (2867)"
334
335 test_19b() {
336     f=$MOUNT/$tfile
337     do_facet client multiop $f Ow  || return 1
338     do_facet client multiop $f or  || return 2
339
340     cancel_lru_locks OSC
341
342     do_facet client multiop $f or  || return 3
343     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
344
345     do_facet client munlink $f  || return 4
346 }
347 run_test 19b "test expired_lock_main on ost (2867)"
348
349 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
350         mkdir -p $DIR/$tdir
351         multiop $DIR/$tdir/${tfile} O_wc &
352         MULTI_PID=$!
353         usleep 500
354         cancel_lru_locks OSC
355 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
356         do_facet ost sysctl -w lustre.fail_loc=0x80000308
357         kill -USR1 $MULTI_PID
358         wait $MULTI_PID
359         rc=$?
360         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
361 }
362 run_test 20a "ldlm_handle_enqueue error (should return error)" 
363
364 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
365         mkdir -p $DIR/$tdir
366         touch $DIR/$tdir/${tfile}
367         cancel_lru_locks OSC
368 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
369         do_facet ost sysctl -w lustre.fail_loc=0x80000308
370         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
371                 error "didn't fail open enqueue" || true
372 }
373 run_test 20b "ldlm_handle_enqueue error (should return error)"
374
375 $CLEANUP