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